{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cfb9d281-6112-45d7-b850-d6ce352dc235",
   "metadata": {},
   "source": [
    "# 环境介绍"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40de32e8-abd9-4a9e-87dd-d8ee53affe40",
   "metadata": {},
   "source": [
    "conda版本：https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Windows-x86_64.exe\n"
   ]
  },
  {
   "cell_type": "raw",
   "id": "3a4ec41e-63aa-42df-9f89-ac07bd5420f2",
   "metadata": {},
   "source": [
    "pip install pymysql==1.0.2 -i https://pypi.douban.com/simple"
   ]
  },
  {
   "cell_type": "raw",
   "id": "bf0e121d-944e-4961-926e-e5290051046e",
   "metadata": {},
   "source": [
    "pip install akshare -i https://pypi.douban.com/simple"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28ff709d-04b9-4fde-baad-8dcdf2ae7494",
   "metadata": {},
   "source": [
    "# 数据库介绍"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b4f27f8e-58e3-42d2-ba6c-b13c0719a51f",
   "metadata": {},
   "source": [
    "菜鸟教程：https://www.runoob.com/mysql/mysql-tutorial.html  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cab5c8dc-d7ec-4a44-92fa-b643bd752faf",
   "metadata": {
    "tags": []
   },
   "source": [
    "## 连接器创建"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "14e2367a-8850-4741-95fb-76fd327b6edf",
   "metadata": {},
   "source": [
    "先手动创建数据库和数据表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "661fea71-4fa8-46b7-af4f-7084a6757e01",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入pymysql模块\n",
    "import pymysql"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "c93d81b9-5709-497c-99e8-ae8df423f0d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 连接database\n",
    "conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', password='biliafan'\n",
    "                       ,database='test', charset='utf8')\n",
    "\n",
    "# 得到一个可以执行SQL语句的光标对象\n",
    "# cursor = conn.cursor()\n",
    "\n",
    "# 得到一个可以执行SQL语句并且将结果作为字典返回的游标\n",
    "cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2aaf9c9-ad7b-4004-a549-884ef97fcf1d",
   "metadata": {},
   "source": [
    "## SQL执行基操"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66030b57-72c8-429e-8d2a-425f86063970",
   "metadata": {},
   "source": [
    "### 查询表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "dd8c2053-fe8a-465d-84d5-a3dc86424c95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sql = \"show tables\"\n",
    "cursor.execute(sql)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a641496-87a5-49af-be53-a69801725a5c",
   "metadata": {},
   "source": [
    "### 查询类的fetchall"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7396bd04-252e-4c67-85f8-5ac2c87e1e40",
   "metadata": {},
   "source": [
    "#### 查询后必须用个变量存下来"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "74a3d47f-676f-47e0-bba5-302e5268e958",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'Tables_in_test': 'newtable'}]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cursor.fetchall()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0999cd3d-e30c-48ed-ae28-cbd250178c9e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cursor.fetchall()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e61431f7-8ea6-4cef-8748-fdf0ffd025c6",
   "metadata": {},
   "source": [
    "#### Python特殊的 _ 变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "769d95a8-9df0-40d7-95d1-a7feb5c89a16",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'Tables_in_test': 'newtable'}]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sql = \"show tables\"\n",
    "cursor.execute(sql)\n",
    "cursor.fetchall()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "b315dba8-1442-4f93-b844-dee28aebd520",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'Tables_in_test': 'newtable'}]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "_"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b181ca2e-a62b-4e87-8bec-8d91679a38f5",
   "metadata": {},
   "source": [
    "### 事务类commit"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "72b8daa3-d62f-48cd-b5b2-97653f265f81",
   "metadata": {},
   "source": [
    "举例：转账问题，你这边扣款成功，但是那边账号不对，所以扣款和余额增加是一步操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28516dcd-fb77-46ec-b5e3-dce65cb19d22",
   "metadata": {},
   "source": [
    "增删改 - 都是事务操作，引发行级锁"
   ]
  },
  {
   "cell_type": "raw",
   "id": "ce5bd2dd-baac-421e-959f-2cec9ccaf510",
   "metadata": {},
   "source": [
    "try:\n",
    "    cursor.execute(sql, [1])\n",
    "    cursor.execute(sql, [1])\n",
    "    # 提交事务\n",
    "    conn.commit()\n",
    "except Exception as e:\n",
    "    # 有异常，回滚事务\n",
    "    conn.rollback()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "524ab6f0-1d78-43b7-8a68-4591b1452239",
   "metadata": {},
   "source": [
    "## 创建表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b9c0e9c-463a-4dc7-b80c-82fcfb4900f2",
   "metadata": {},
   "source": [
    "通常每张表都会有一个字段或者多个字段联合起来唯一标识表记录，这样的字段成为这张表的主键，我们可以为这样的字段增加主键约束，**主键约束要求字段必须不能为空且值必须唯一**\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5bcca47c-4e7b-403d-8ec0-e1d6915b432a",
   "metadata": {},
   "source": [
    "- 定义主键约束:PRIMARY KEY\n",
    "- 定义唯一约束：unique\n",
    "- 定义非空约束：not null"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a2df19b-14e8-4f14-864a-47a22bde66db",
   "metadata": {},
   "source": [
    "注意：\n",
    "- 1 建表，一定要慎重，要和业务逻辑和技术要求相符合\n",
    "- 2 不要和mysql关键字重合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "bfd3b991-37d7-4165-9c7c-e33b38628152",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义要执行的SQL语句\n",
    "sql = \"\"\"\n",
    "CREATE TABLE USER (\n",
    "id INT auto_increment PRIMARY KEY, \n",
    "name VARCHAR(10) NOT NULL UNIQUE,\n",
    "pwd VARCHAR(16) NOT NULL,\n",
    "date TIMESTAMP\n",
    ")ENGINE=innodb DEFAULT CHARSET=utf8;\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a59d35e1-bc9d-4c5c-8917-dee89434e241",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 执行SQL语句\n",
    "cursor.execute(sql)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fb33017-ff63-4837-97bd-93102ebcfb44",
   "metadata": {},
   "source": [
    "## 关闭连接"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b7c6c563-cd55-45f2-880f-fdcd7226375f",
   "metadata": {},
   "source": [
    "操作完主动关闭连接，减少资源消耗"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "id": "56c64a92-7051-485f-b618-dba46d75dd3c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 关闭光标对象\n",
    "cursor.close()\n",
    "\n",
    "# 关闭数据库连接\n",
    "conn.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d3d13d7c-5cba-4f23-b021-8b0f844b4f64",
   "metadata": {},
   "source": [
    "## 增删改查训练"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "445ce91b-b48f-4e3d-8bb3-417df9d69b80",
   "metadata": {
    "tags": []
   },
   "source": [
    "### 增"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "099234c0-3bd9-42dd-96af-cba182d8003a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "89cb9a1b-1aa0-436a-8436-1b414dd5f25c",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"INSERT INTO USER(name, pwd, date) VALUES (%s, %s, %s);\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "efe67bff-e920-44f0-98ae-9c8dec6b4ba7",
   "metadata": {},
   "outputs": [],
   "source": [
    "username = \"Frank\"\n",
    "pwd = 123456\n",
    "date = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "b6805d77-40d2-43d5-a312-6ab08642d293",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 执行SQL语句\n",
    "cursor.execute(sql, [username, pwd, date])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "28ee2828-894c-45dc-8a61-6351ee64eb3e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 提交事务\n",
    "conn.commit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5c93402a-7e9d-4203-b6b4-0795fa53eb09",
   "metadata": {},
   "source": [
    "### 查"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "93e842fb-49df-44b6-9d09-d8b93d7b1e42",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 编写sql 查询语句  user 对应我的表名  \n",
    "sql = \"select * from USER\"  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "46f68a60-0332-45ef-b9f9-70f9d4f1ecf6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cursor.execute(sql)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "8a686117-dd2c-490e-9d44-88c98128bd92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 1,\n",
       "  'name': 'Frank',\n",
       "  'pwd': '123456',\n",
       "  'date': datetime.datetime(2023, 2, 2, 0, 28, 21)}]"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cursor.fetchall()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "6e6ad8ad-77e4-44fa-8805-e53b41a6979a",
   "metadata": {},
   "outputs": [],
   "source": [
    "results = _"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "d23b0821-fbd9-47a9-a180-2556953227f0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "59df12a2-ebdd-459b-a07a-f81d356a5486",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>name</th>\n",
       "      <th>pwd</th>\n",
       "      <th>date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Frank</td>\n",
       "      <td>123456</td>\n",
       "      <td>2023-02-02 00:28:21</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id   name     pwd                date\n",
       "0   1  Frank  123456 2023-02-02 00:28:21"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(results)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "877867c5-64f8-4e38-a017-a47e88b44f09",
   "metadata": {},
   "source": [
    "### 改"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "903743b6-9178-499f-bc25-317db69030eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 修改数据的SQL语句\n",
    "sql = \"UPDATE USER SET pwd=%s WHERE name=%s;\"\n",
    "username = \"Frank\"\n",
    "newpwd = 654321"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "9802c49a-1d82-4aca-82e4-5d41b43cb52a",
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    # 执行SQL语句\n",
    "    cursor.execute(sql, [newpwd, username])\n",
    "    # 提交事务\n",
    "    conn.commit()\n",
    "except Exception as e:\n",
    "    print(e)\n",
    "    # 有异常，回滚事务\n",
    "    conn.rollback()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fe6903c2-4804-482e-a45f-865efd65430e",
   "metadata": {},
   "source": [
    "### 删"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "031fa450-a171-4028-ab39-2618cfee88f1",
   "metadata": {},
   "source": [
    "如果用户不再使用了，需要把TA的记录给删除"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "576eb7a4-dd26-4bad-91d1-39a51530ada0",
   "metadata": {},
   "source": [
    "注：真实业务场景中，任何业务数据都是有价值的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "99fc8915-21e5-49ee-9000-ae746c24304b",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"DELETE FROM USER WHERE name=%s;\"\n",
    "try:\n",
    "    cursor.execute(sql, ['Frank'])\n",
    "    # 提交事务\n",
    "    conn.commit()\n",
    "except Exception as e:\n",
    "    # 有异常，回滚事务\n",
    "    conn.rollback()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "92692d59-4873-4ff9-83ec-a9170fff0993",
   "metadata": {},
   "source": [
    "## 进阶操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "05daa05f-e472-4980-bf1c-af7374d6a44a",
   "metadata": {},
   "source": [
    "### 操作回滚"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "b7ebb473-a4bc-4b1e-88d6-ff7e22028571",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"INSERT INTO USER(name, pwd, date) VALUES (%s, %s, %s);\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "c7e890dd-2f03-4907-8ee4-9fd4722253d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "username = \"kangkang\"\n",
    "pwd = 123456\n",
    "date = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "09bd72dd-2ca0-4632-96db-58c139762061",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1062, \"Duplicate entry 'kangkang' for key 'user.name'\")\n"
     ]
    }
   ],
   "source": [
    "try:\n",
    "    # 执行SQL语句\n",
    "    cursor.execute(sql, [username, pwd, date])\n",
    "    # 这一句会报错\n",
    "    cursor.execute(sql, [username, pwd, date])\n",
    "    # 提交事务\n",
    "    conn.commit()\n",
    "except Exception as e:\n",
    "    print(e)\n",
    "    # 有异常，回滚事务\n",
    "    conn.rollback()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "13a30995-c21b-4141-8daf-dd82291740c2",
   "metadata": {},
   "source": [
    "### 批量执行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "42ab1c40-d26a-4ea4-9504-2f079d3a5b6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"INSERT INTO USER(name, pwd, date) VALUES (%s, %s, %s);\"\n",
    "data = [(\"Frank\", 18, datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")  )\n",
    "        , (\"DIDI\", 20, datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")  )\n",
    "        , (\"HAHA\", 21, datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")  )]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "5b8c19c0-8b22-4967-9e35-4c563dc0f9f4",
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    # 批量执行多条插入SQL语句\n",
    "    cursor.executemany(sql, data)\n",
    "    # 提交事务\n",
    "    conn.commit()\n",
    "except Exception as e:\n",
    "    print(e)\n",
    "    # 有异常，回滚事务\n",
    "    conn.rollback()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "e06b5676-efa8-4aaf-b9d3-d2dd05800f97",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 4,\n",
       "  'name': 'Frank',\n",
       "  'pwd': '18',\n",
       "  'date': datetime.datetime(2023, 2, 2, 0, 44, 50)},\n",
       " {'id': 5,\n",
       "  'name': 'DIDI',\n",
       "  'pwd': '20',\n",
       "  'date': datetime.datetime(2023, 2, 2, 0, 44, 50)},\n",
       " {'id': 6,\n",
       "  'name': 'HAHA',\n",
       "  'pwd': '21',\n",
       "  'date': datetime.datetime(2023, 2, 2, 0, 44, 50)}]"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 编写sql 查询语句  user 对应我的表名  \n",
    "sql = \"select * from USER\"  \n",
    "cursor.execute(sql)\n",
    "cursor.fetchall()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f9219335-ec96-4c54-95e5-bfb31b97f2d7",
   "metadata": {},
   "source": [
    "# AKSHARE行情数据存储"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "4d1fca3c-caf6-4493-b056-9bb2b0d476d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import akshare as ak"
   ]
  },
  {
   "cell_type": "raw",
   "id": "fc4e920d-31db-4fcb-b9ec-66b7c98306c8",
   "metadata": {},
   "source": [
    "pip install akshare -i https://pypi.douban.com/simple"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b984ebe-a935-45e1-a11e-f30e865b1ad8",
   "metadata": {},
   "source": [
    "## 获取所有股票的列表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f29e9a98-ce2c-49e8-ae82-32847700a842",
   "metadata": {},
   "source": [
    "缺点体现：没有一个接口同时获取所有股票信息，股票缺少行业的等字段，接口不统一（没有进行多源重构）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "07861752-ea3c-4966-a92b-3b9c9e6d0707",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_df = ak.stock_zh_a_spot_em() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "1ad06419-db3b-4f66-9957-941c5341e3fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>最新价</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>最高</th>\n",
       "      <th>...</th>\n",
       "      <th>量比</th>\n",
       "      <th>换手率</th>\n",
       "      <th>市盈率-动态</th>\n",
       "      <th>市净率</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "      <th>涨速</th>\n",
       "      <th>5分钟涨跌</th>\n",
       "      <th>60日涨跌幅</th>\n",
       "      <th>年初至今涨跌幅</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>601059</td>\n",
       "      <td>N信达</td>\n",
       "      <td>11.88</td>\n",
       "      <td>44.00</td>\n",
       "      <td>3.63</td>\n",
       "      <td>77071.0</td>\n",
       "      <td>9.116085e+07</td>\n",
       "      <td>24.00</td>\n",
       "      <td>11.88</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.38</td>\n",
       "      <td>39.92</td>\n",
       "      <td>2.44</td>\n",
       "      <td>3.852684e+10</td>\n",
       "      <td>3.852684e+09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>44.00</td>\n",
       "      <td>44.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>831526</td>\n",
       "      <td>凯华材料</td>\n",
       "      <td>7.28</td>\n",
       "      <td>27.27</td>\n",
       "      <td>1.56</td>\n",
       "      <td>119716.0</td>\n",
       "      <td>8.369095e+07</td>\n",
       "      <td>26.75</td>\n",
       "      <td>7.43</td>\n",
       "      <td>...</td>\n",
       "      <td>5.06</td>\n",
       "      <td>56.79</td>\n",
       "      <td>35.67</td>\n",
       "      <td>3.32</td>\n",
       "      <td>6.020560e+08</td>\n",
       "      <td>1.534629e+08</td>\n",
       "      <td>0.14</td>\n",
       "      <td>0.28</td>\n",
       "      <td>12.00</td>\n",
       "      <td>76.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>300309</td>\n",
       "      <td>*ST吉艾</td>\n",
       "      <td>1.01</td>\n",
       "      <td>20.24</td>\n",
       "      <td>0.17</td>\n",
       "      <td>1820609.0</td>\n",
       "      <td>1.773054e+08</td>\n",
       "      <td>17.86</td>\n",
       "      <td>1.01</td>\n",
       "      <td>...</td>\n",
       "      <td>1.67</td>\n",
       "      <td>21.74</td>\n",
       "      <td>-1.75</td>\n",
       "      <td>-0.76</td>\n",
       "      <td>8.949850e+08</td>\n",
       "      <td>8.457909e+08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-28.87</td>\n",
       "      <td>-29.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>300044</td>\n",
       "      <td>赛为智能</td>\n",
       "      <td>5.45</td>\n",
       "      <td>20.04</td>\n",
       "      <td>0.91</td>\n",
       "      <td>2910558.0</td>\n",
       "      <td>1.490658e+09</td>\n",
       "      <td>16.52</td>\n",
       "      <td>5.45</td>\n",
       "      <td>...</td>\n",
       "      <td>3.60</td>\n",
       "      <td>43.49</td>\n",
       "      <td>-104.37</td>\n",
       "      <td>4.18</td>\n",
       "      <td>4.197379e+09</td>\n",
       "      <td>3.647135e+09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>61.24</td>\n",
       "      <td>92.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>300084</td>\n",
       "      <td>海默科技</td>\n",
       "      <td>6.05</td>\n",
       "      <td>20.04</td>\n",
       "      <td>1.01</td>\n",
       "      <td>565386.0</td>\n",
       "      <td>3.226772e+08</td>\n",
       "      <td>19.64</td>\n",
       "      <td>6.05</td>\n",
       "      <td>...</td>\n",
       "      <td>7.28</td>\n",
       "      <td>17.15</td>\n",
       "      <td>-38.70</td>\n",
       "      <td>2.36</td>\n",
       "      <td>2.327833e+09</td>\n",
       "      <td>1.995001e+09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>44.39</td>\n",
       "      <td>37.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5274</th>\n",
       "      <td>5275</td>\n",
       "      <td>002848</td>\n",
       "      <td>高斯贝尔</td>\n",
       "      <td>12.32</td>\n",
       "      <td>-5.95</td>\n",
       "      <td>-0.78</td>\n",
       "      <td>505767.0</td>\n",
       "      <td>6.106837e+08</td>\n",
       "      <td>5.11</td>\n",
       "      <td>12.46</td>\n",
       "      <td>...</td>\n",
       "      <td>1.53</td>\n",
       "      <td>31.46</td>\n",
       "      <td>52.09</td>\n",
       "      <td>8.04</td>\n",
       "      <td>2.059288e+09</td>\n",
       "      <td>1.980763e+09</td>\n",
       "      <td>0.08</td>\n",
       "      <td>0.33</td>\n",
       "      <td>18.23</td>\n",
       "      <td>32.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5275</th>\n",
       "      <td>5276</td>\n",
       "      <td>300763</td>\n",
       "      <td>锦浪科技</td>\n",
       "      <td>171.35</td>\n",
       "      <td>-6.42</td>\n",
       "      <td>-11.76</td>\n",
       "      <td>104692.0</td>\n",
       "      <td>1.809343e+09</td>\n",
       "      <td>8.35</td>\n",
       "      <td>183.50</td>\n",
       "      <td>...</td>\n",
       "      <td>2.60</td>\n",
       "      <td>3.49</td>\n",
       "      <td>68.92</td>\n",
       "      <td>16.62</td>\n",
       "      <td>6.463124e+10</td>\n",
       "      <td>5.140664e+10</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.05</td>\n",
       "      <td>-9.23</td>\n",
       "      <td>-4.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5276</th>\n",
       "      <td>5277</td>\n",
       "      <td>001236</td>\n",
       "      <td>弘业期货</td>\n",
       "      <td>20.19</td>\n",
       "      <td>-6.74</td>\n",
       "      <td>-1.46</td>\n",
       "      <td>540560.0</td>\n",
       "      <td>1.091288e+09</td>\n",
       "      <td>8.87</td>\n",
       "      <td>21.43</td>\n",
       "      <td>...</td>\n",
       "      <td>1.22</td>\n",
       "      <td>53.64</td>\n",
       "      <td>529.20</td>\n",
       "      <td>10.92</td>\n",
       "      <td>2.034703e+10</td>\n",
       "      <td>2.034703e+09</td>\n",
       "      <td>-0.10</td>\n",
       "      <td>-1.03</td>\n",
       "      <td>-2.51</td>\n",
       "      <td>49.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5277</th>\n",
       "      <td>5278</td>\n",
       "      <td>833523</td>\n",
       "      <td>德瑞锂电</td>\n",
       "      <td>14.87</td>\n",
       "      <td>-7.18</td>\n",
       "      <td>-1.15</td>\n",
       "      <td>37249.0</td>\n",
       "      <td>5.628414e+07</td>\n",
       "      <td>11.11</td>\n",
       "      <td>16.18</td>\n",
       "      <td>...</td>\n",
       "      <td>2.70</td>\n",
       "      <td>7.91</td>\n",
       "      <td>26.40</td>\n",
       "      <td>3.01</td>\n",
       "      <td>1.158732e+09</td>\n",
       "      <td>7.003969e+08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-0.13</td>\n",
       "      <td>13.51</td>\n",
       "      <td>24.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5278</th>\n",
       "      <td>5279</td>\n",
       "      <td>603668</td>\n",
       "      <td>天马科技</td>\n",
       "      <td>18.00</td>\n",
       "      <td>-9.95</td>\n",
       "      <td>-1.99</td>\n",
       "      <td>558593.0</td>\n",
       "      <td>1.005207e+09</td>\n",
       "      <td>0.40</td>\n",
       "      <td>18.07</td>\n",
       "      <td>...</td>\n",
       "      <td>7.67</td>\n",
       "      <td>12.81</td>\n",
       "      <td>24.42</td>\n",
       "      <td>3.67</td>\n",
       "      <td>7.850430e+09</td>\n",
       "      <td>7.850430e+09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.06</td>\n",
       "      <td>4.77</td>\n",
       "      <td>0.45</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5279 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        序号      代码     名称     最新价    涨跌幅    涨跌额        成交量           成交额  \\\n",
       "0        1  601059    N信达   11.88  44.00   3.63    77071.0  9.116085e+07   \n",
       "1        2  831526   凯华材料    7.28  27.27   1.56   119716.0  8.369095e+07   \n",
       "2        3  300309  *ST吉艾    1.01  20.24   0.17  1820609.0  1.773054e+08   \n",
       "3        4  300044   赛为智能    5.45  20.04   0.91  2910558.0  1.490658e+09   \n",
       "4        5  300084   海默科技    6.05  20.04   1.01   565386.0  3.226772e+08   \n",
       "...    ...     ...    ...     ...    ...    ...        ...           ...   \n",
       "5274  5275  002848   高斯贝尔   12.32  -5.95  -0.78   505767.0  6.106837e+08   \n",
       "5275  5276  300763   锦浪科技  171.35  -6.42 -11.76   104692.0  1.809343e+09   \n",
       "5276  5277  001236   弘业期货   20.19  -6.74  -1.46   540560.0  1.091288e+09   \n",
       "5277  5278  833523   德瑞锂电   14.87  -7.18  -1.15    37249.0  5.628414e+07   \n",
       "5278  5279  603668   天马科技   18.00  -9.95  -1.99   558593.0  1.005207e+09   \n",
       "\n",
       "         振幅      最高  ...    量比    换手率  市盈率-动态    市净率           总市值  \\\n",
       "0     24.00   11.88  ...   NaN   2.38   39.92   2.44  3.852684e+10   \n",
       "1     26.75    7.43  ...  5.06  56.79   35.67   3.32  6.020560e+08   \n",
       "2     17.86    1.01  ...  1.67  21.74   -1.75  -0.76  8.949850e+08   \n",
       "3     16.52    5.45  ...  3.60  43.49 -104.37   4.18  4.197379e+09   \n",
       "4     19.64    6.05  ...  7.28  17.15  -38.70   2.36  2.327833e+09   \n",
       "...     ...     ...  ...   ...    ...     ...    ...           ...   \n",
       "5274   5.11   12.46  ...  1.53  31.46   52.09   8.04  2.059288e+09   \n",
       "5275   8.35  183.50  ...  2.60   3.49   68.92  16.62  6.463124e+10   \n",
       "5276   8.87   21.43  ...  1.22  53.64  529.20  10.92  2.034703e+10   \n",
       "5277  11.11   16.18  ...  2.70   7.91   26.40   3.01  1.158732e+09   \n",
       "5278   0.40   18.07  ...  7.67  12.81   24.42   3.67  7.850430e+09   \n",
       "\n",
       "              流通市值    涨速  5分钟涨跌  60日涨跌幅  年初至今涨跌幅  \n",
       "0     3.852684e+09  0.00   0.00   44.00    44.00  \n",
       "1     1.534629e+08  0.14   0.28   12.00    76.70  \n",
       "2     8.457909e+08  0.00   0.00  -28.87   -29.37  \n",
       "3     3.647135e+09  0.00   0.00   61.24    92.58  \n",
       "4     1.995001e+09  0.00   0.00   44.39    37.19  \n",
       "...            ...   ...    ...     ...      ...  \n",
       "5274  1.980763e+09  0.08   0.33   18.23    32.76  \n",
       "5275  5.140664e+10  0.02   0.05   -9.23    -4.83  \n",
       "5276  2.034703e+09 -0.10  -1.03   -2.51    49.33  \n",
       "5277  7.003969e+08  0.00  -0.13   13.51    24.96  \n",
       "5278  7.850430e+09  0.00   0.06    4.77     0.45  \n",
       "\n",
       "[5279 rows x 23 columns]"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "209dbb62-e15e-4da2-b76e-2da95264bf3c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['序号', '代码', '名称', '最新价', '涨跌幅', '涨跌额', '成交量', '成交额', '振幅', '最高', '最低',\n",
       "       '今开', '昨收', '量比', '换手率', '市盈率-动态', '市净率', '总市值', '流通市值', '涨速', '5分钟涨跌',\n",
       "       '60日涨跌幅', '年初至今涨跌幅'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_df.columns"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6c264d0-7c6d-4ee3-9b1a-e63a99488cc6",
   "metadata": {},
   "source": [
    "## 获取所有股票历史行情"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75de2574-e7f6-4fab-9a2f-04a7c57d6478",
   "metadata": {},
   "source": [
    "### 股票复权原理"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dde547b5-214a-45d2-bf79-d662c1d867b9",
   "metadata": {},
   "source": [
    "很用心官网做了解释：https://www.akshare.xyz/data/stock/stock.html#id19"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "372f6c95-4d06-4929-8dd5-baab6eb7cf8b",
   "metadata": {},
   "source": [
    "[其他参考](https://mp.weixin.qq.com/s?__biz=MzUxMjU4NDAwNA==&mid=2247484072&idx=1&sn=501e720447b6cf1b5544795e8f226a8d)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8d7d216-82aa-408c-b0b0-6dacc5bb0fdc",
   "metadata": {},
   "source": [
    "股票数据复权\n",
    "\n",
    "1.为何要复权：由于股票存在配股、分拆、合并和发放股息等事件，会导致股价出现较大的缺口。 若使用不复权的价格处理数据、计算各种指标，将会导致它们失去连续性，且使用不复权价格计算收益也会出现错误。 为了保证数据连贯性，常通过前复权和后复权对价格序列进行调整。\n",
    "\n",
    "2.前复权：保持当前价格不变，将历史价格进行增减，从而使股价连续。 前复权用来看盘非常方便，能一眼看出股价的历史走势，叠加各种技术指标也比较顺畅，是各种行情软件默认的复权方式。 这种方法虽然很常见，但也有两个缺陷需要注意。\n",
    "\n",
    "2.1 为了保证当前价格不变，每次股票除权除息，均需要重新调整历史价格，因此其历史价格是时变的。 这会导致在不同时点看到的历史前复权价可能出现差异。\n",
    "\n",
    "2.2 对于有持续分红的公司来说，前复权价可能出现负值。\n",
    "\n",
    "3.后复权：保证历史价格不变，在每次股票权益事件发生后，调整当前的股票价格。 后复权价格和真实股票价格可能差别较大，不适合用来看盘。 其优点在于，可以被看作投资者的长期财富增长曲线，反映投资者的真实收益率情况。\n",
    "\n",
    "4.在量化投资研究中普遍采用后复权数据。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6b9f6d1-41bb-4e74-b8cf-25a87e911f02",
   "metadata": {},
   "source": [
    "以中信证券为例：https://data.eastmoney.com/yjfp/detail/600030.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "3b9e07d4-c9a3-4b19-85f6-415ec065be30",
   "metadata": {},
   "outputs": [],
   "source": [
    "hfq = ak.stock_zh_a_hist(symbol=\"600030\", period=\"daily\", start_date=\"20000101\", end_date='20230201'\n",
    "                   , adjust=\"hfq\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "cb3ff699-11d5-48ec-88f2-4c99eee16361",
   "metadata": {},
   "outputs": [],
   "source": [
    "qfq = ak.stock_zh_a_hist(symbol=\"600030\", period=\"daily\", start_date=\"20000101\", end_date='20230201'\n",
    "                   , adjust=\"qfq\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "080b2241-13b0-4b0f-b4fb-91e490e02f51",
   "metadata": {},
   "outputs": [],
   "source": [
    "bfq = ak.stock_zh_a_hist(symbol=\"600030\", period=\"daily\", start_date=\"20000101\", end_date='20230201'\n",
    "                   , adjust=\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "918efaf2-e3d2-40eb-b1c4-934433c04fe7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "845bf129-a53e-4a69-b256-39fb665a1d8f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>收盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>换手率</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1225</th>\n",
       "      <td>2008-04-22</td>\n",
       "      <td>53.75</td>\n",
       "      <td>56.19</td>\n",
       "      <td>56.38</td>\n",
       "      <td>51.50</td>\n",
       "      <td>372972</td>\n",
       "      <td>1.997202e+09</td>\n",
       "      <td>8.87</td>\n",
       "      <td>2.15</td>\n",
       "      <td>1.18</td>\n",
       "      <td>1.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1226</th>\n",
       "      <td>2008-04-23</td>\n",
       "      <td>55.68</td>\n",
       "      <td>58.92</td>\n",
       "      <td>59.80</td>\n",
       "      <td>55.00</td>\n",
       "      <td>728468</td>\n",
       "      <td>4.245771e+09</td>\n",
       "      <td>8.54</td>\n",
       "      <td>4.86</td>\n",
       "      <td>2.73</td>\n",
       "      <td>2.61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1227</th>\n",
       "      <td>2008-04-24</td>\n",
       "      <td>32.13</td>\n",
       "      <td>32.13</td>\n",
       "      <td>32.13</td>\n",
       "      <td>32.13</td>\n",
       "      <td>144058</td>\n",
       "      <td>4.628576e+08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-45.47</td>\n",
       "      <td>-26.79</td>\n",
       "      <td>0.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1228</th>\n",
       "      <td>2008-04-25</td>\n",
       "      <td>35.34</td>\n",
       "      <td>35.34</td>\n",
       "      <td>35.34</td>\n",
       "      <td>34.50</td>\n",
       "      <td>3762451</td>\n",
       "      <td>1.327501e+10</td>\n",
       "      <td>2.61</td>\n",
       "      <td>9.99</td>\n",
       "      <td>3.21</td>\n",
       "      <td>6.74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1229</th>\n",
       "      <td>2008-04-28</td>\n",
       "      <td>35.00</td>\n",
       "      <td>35.12</td>\n",
       "      <td>36.25</td>\n",
       "      <td>34.61</td>\n",
       "      <td>2920598</td>\n",
       "      <td>1.043327e+10</td>\n",
       "      <td>4.64</td>\n",
       "      <td>-0.62</td>\n",
       "      <td>-0.22</td>\n",
       "      <td>5.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1230</th>\n",
       "      <td>2008-04-29</td>\n",
       "      <td>34.50</td>\n",
       "      <td>36.84</td>\n",
       "      <td>36.88</td>\n",
       "      <td>34.30</td>\n",
       "      <td>2072000</td>\n",
       "      <td>7.417317e+09</td>\n",
       "      <td>7.35</td>\n",
       "      <td>4.90</td>\n",
       "      <td>1.72</td>\n",
       "      <td>3.71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1231</th>\n",
       "      <td>2008-04-30</td>\n",
       "      <td>36.90</td>\n",
       "      <td>39.64</td>\n",
       "      <td>40.08</td>\n",
       "      <td>36.54</td>\n",
       "      <td>2596786</td>\n",
       "      <td>1.008130e+10</td>\n",
       "      <td>9.61</td>\n",
       "      <td>7.60</td>\n",
       "      <td>2.80</td>\n",
       "      <td>4.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1232</th>\n",
       "      <td>2008-05-05</td>\n",
       "      <td>40.50</td>\n",
       "      <td>40.13</td>\n",
       "      <td>40.64</td>\n",
       "      <td>39.10</td>\n",
       "      <td>2131515</td>\n",
       "      <td>8.523442e+09</td>\n",
       "      <td>3.88</td>\n",
       "      <td>1.24</td>\n",
       "      <td>0.49</td>\n",
       "      <td>3.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1233</th>\n",
       "      <td>2008-05-06</td>\n",
       "      <td>39.21</td>\n",
       "      <td>40.82</td>\n",
       "      <td>43.00</td>\n",
       "      <td>38.43</td>\n",
       "      <td>2844210</td>\n",
       "      <td>1.149187e+10</td>\n",
       "      <td>11.39</td>\n",
       "      <td>1.72</td>\n",
       "      <td>0.69</td>\n",
       "      <td>5.09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1234</th>\n",
       "      <td>2008-05-07</td>\n",
       "      <td>39.70</td>\n",
       "      <td>37.78</td>\n",
       "      <td>40.91</td>\n",
       "      <td>37.66</td>\n",
       "      <td>1935407</td>\n",
       "      <td>7.631245e+09</td>\n",
       "      <td>7.96</td>\n",
       "      <td>-7.45</td>\n",
       "      <td>-3.04</td>\n",
       "      <td>3.47</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              日期     开盘     收盘     最高     最低      成交量           成交额     振幅  \\\n",
       "1225  2008-04-22  53.75  56.19  56.38  51.50   372972  1.997202e+09   8.87   \n",
       "1226  2008-04-23  55.68  58.92  59.80  55.00   728468  4.245771e+09   8.54   \n",
       "1227  2008-04-24  32.13  32.13  32.13  32.13   144058  4.628576e+08   0.00   \n",
       "1228  2008-04-25  35.34  35.34  35.34  34.50  3762451  1.327501e+10   2.61   \n",
       "1229  2008-04-28  35.00  35.12  36.25  34.61  2920598  1.043327e+10   4.64   \n",
       "1230  2008-04-29  34.50  36.84  36.88  34.30  2072000  7.417317e+09   7.35   \n",
       "1231  2008-04-30  36.90  39.64  40.08  36.54  2596786  1.008130e+10   9.61   \n",
       "1232  2008-05-05  40.50  40.13  40.64  39.10  2131515  8.523442e+09   3.88   \n",
       "1233  2008-05-06  39.21  40.82  43.00  38.43  2844210  1.149187e+10  11.39   \n",
       "1234  2008-05-07  39.70  37.78  40.91  37.66  1935407  7.631245e+09   7.96   \n",
       "\n",
       "        涨跌幅    涨跌额   换手率  \n",
       "1225   2.15   1.18  1.34  \n",
       "1226   4.86   2.73  2.61  \n",
       "1227 -45.47 -26.79  0.26  \n",
       "1228   9.99   3.21  6.74  \n",
       "1229  -0.62  -0.22  5.23  \n",
       "1230   4.90   1.72  3.71  \n",
       "1231   7.60   2.80  4.65  \n",
       "1232   1.24   0.49  3.82  \n",
       "1233   1.72   0.69  5.09  \n",
       "1234  -7.45  -3.04  3.47  "
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bfq.iloc[1225:, ].head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "72208dcb-459d-42b1-b40f-fb8555752687",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>收盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>换手率</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1225</th>\n",
       "      <td>2008-04-22</td>\n",
       "      <td>54.23</td>\n",
       "      <td>56.67</td>\n",
       "      <td>56.86</td>\n",
       "      <td>51.98</td>\n",
       "      <td>372972</td>\n",
       "      <td>1.997202e+09</td>\n",
       "      <td>8.79</td>\n",
       "      <td>2.13</td>\n",
       "      <td>1.18</td>\n",
       "      <td>1.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1226</th>\n",
       "      <td>2008-04-23</td>\n",
       "      <td>56.16</td>\n",
       "      <td>59.40</td>\n",
       "      <td>60.28</td>\n",
       "      <td>55.48</td>\n",
       "      <td>728468</td>\n",
       "      <td>4.245771e+09</td>\n",
       "      <td>8.47</td>\n",
       "      <td>4.82</td>\n",
       "      <td>2.73</td>\n",
       "      <td>2.61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1227</th>\n",
       "      <td>2008-04-24</td>\n",
       "      <td>65.24</td>\n",
       "      <td>65.24</td>\n",
       "      <td>65.24</td>\n",
       "      <td>65.24</td>\n",
       "      <td>144058</td>\n",
       "      <td>4.628576e+08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>9.83</td>\n",
       "      <td>5.84</td>\n",
       "      <td>0.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1228</th>\n",
       "      <td>2008-04-25</td>\n",
       "      <td>71.66</td>\n",
       "      <td>71.66</td>\n",
       "      <td>71.66</td>\n",
       "      <td>69.98</td>\n",
       "      <td>3762451</td>\n",
       "      <td>1.327501e+10</td>\n",
       "      <td>2.58</td>\n",
       "      <td>9.84</td>\n",
       "      <td>6.42</td>\n",
       "      <td>6.74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1229</th>\n",
       "      <td>2008-04-28</td>\n",
       "      <td>70.98</td>\n",
       "      <td>71.22</td>\n",
       "      <td>73.48</td>\n",
       "      <td>70.20</td>\n",
       "      <td>2920598</td>\n",
       "      <td>1.043327e+10</td>\n",
       "      <td>4.58</td>\n",
       "      <td>-0.61</td>\n",
       "      <td>-0.44</td>\n",
       "      <td>5.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1230</th>\n",
       "      <td>2008-04-29</td>\n",
       "      <td>69.98</td>\n",
       "      <td>74.66</td>\n",
       "      <td>74.74</td>\n",
       "      <td>69.58</td>\n",
       "      <td>2072000</td>\n",
       "      <td>7.417317e+09</td>\n",
       "      <td>7.25</td>\n",
       "      <td>4.83</td>\n",
       "      <td>3.44</td>\n",
       "      <td>3.71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1231</th>\n",
       "      <td>2008-04-30</td>\n",
       "      <td>74.78</td>\n",
       "      <td>80.26</td>\n",
       "      <td>81.14</td>\n",
       "      <td>74.06</td>\n",
       "      <td>2596786</td>\n",
       "      <td>1.008130e+10</td>\n",
       "      <td>9.48</td>\n",
       "      <td>7.50</td>\n",
       "      <td>5.60</td>\n",
       "      <td>4.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1232</th>\n",
       "      <td>2008-05-05</td>\n",
       "      <td>81.98</td>\n",
       "      <td>81.24</td>\n",
       "      <td>82.26</td>\n",
       "      <td>79.18</td>\n",
       "      <td>2131515</td>\n",
       "      <td>8.523442e+09</td>\n",
       "      <td>3.84</td>\n",
       "      <td>1.22</td>\n",
       "      <td>0.98</td>\n",
       "      <td>3.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1233</th>\n",
       "      <td>2008-05-06</td>\n",
       "      <td>79.40</td>\n",
       "      <td>82.62</td>\n",
       "      <td>86.98</td>\n",
       "      <td>77.84</td>\n",
       "      <td>2844210</td>\n",
       "      <td>1.149187e+10</td>\n",
       "      <td>11.25</td>\n",
       "      <td>1.70</td>\n",
       "      <td>1.38</td>\n",
       "      <td>5.09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1234</th>\n",
       "      <td>2008-05-07</td>\n",
       "      <td>80.38</td>\n",
       "      <td>76.54</td>\n",
       "      <td>82.80</td>\n",
       "      <td>76.30</td>\n",
       "      <td>1935407</td>\n",
       "      <td>7.631245e+09</td>\n",
       "      <td>7.87</td>\n",
       "      <td>-7.36</td>\n",
       "      <td>-6.08</td>\n",
       "      <td>3.47</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              日期     开盘     收盘     最高     最低      成交量           成交额     振幅  \\\n",
       "1225  2008-04-22  54.23  56.67  56.86  51.98   372972  1.997202e+09   8.79   \n",
       "1226  2008-04-23  56.16  59.40  60.28  55.48   728468  4.245771e+09   8.47   \n",
       "1227  2008-04-24  65.24  65.24  65.24  65.24   144058  4.628576e+08   0.00   \n",
       "1228  2008-04-25  71.66  71.66  71.66  69.98  3762451  1.327501e+10   2.58   \n",
       "1229  2008-04-28  70.98  71.22  73.48  70.20  2920598  1.043327e+10   4.58   \n",
       "1230  2008-04-29  69.98  74.66  74.74  69.58  2072000  7.417317e+09   7.25   \n",
       "1231  2008-04-30  74.78  80.26  81.14  74.06  2596786  1.008130e+10   9.48   \n",
       "1232  2008-05-05  81.98  81.24  82.26  79.18  2131515  8.523442e+09   3.84   \n",
       "1233  2008-05-06  79.40  82.62  86.98  77.84  2844210  1.149187e+10  11.25   \n",
       "1234  2008-05-07  80.38  76.54  82.80  76.30  1935407  7.631245e+09   7.87   \n",
       "\n",
       "       涨跌幅   涨跌额   换手率  \n",
       "1225  2.13  1.18  1.34  \n",
       "1226  4.82  2.73  2.61  \n",
       "1227  9.83  5.84  0.26  \n",
       "1228  9.84  6.42  6.74  \n",
       "1229 -0.61 -0.44  5.23  \n",
       "1230  4.83  3.44  3.71  \n",
       "1231  7.50  5.60  4.65  \n",
       "1232  1.22  0.98  3.82  \n",
       "1233  1.70  1.38  5.09  \n",
       "1234 -7.36 -6.08  3.47  "
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hfq.iloc[1225:, ].head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "85b89107-9cd8-47a6-8999-e67b9ae5b11b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x17761472c10>"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAD4CAYAAAAO9oqkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAABiN0lEQVR4nO2dd3gU1d6A37ObRgi99ybSkSoIgkhTwd5REXu56tX72TvXcu312kW9WLFXFEGKgNJr6DVAqCGQkJ4t5/tjdnZnd2c3WxJ2Nznv8+TZmdkzs2c2yfzOrwspJQqFQqGo2VhiPQGFQqFQxB4lDBQKhUKhhIFCoVAolDBQKBQKBUoYKBQKhQJIivUEABo3bizbt28f62koFApFQrFixYrDUsomlXGtuBAG7du3Z/ny5bGehkKhUCQUQohdlXUtZSZSKBQKhRIGCoVCoVDCQKFQKBTEic/ADJvNRnZ2NqWlpbGeS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orzaSU+0F7YAJNXccDfQ+tXNu+xxMGIUR7oC/a6rjG3L/LTLIaOATMklLWpPt/FbgPcBqO1ZR7B03wzxRCrBBC3OQ6dlzuv8p6IB8HzGxgNTFONtD3kNDfjxAiA/gWuEtKeSyIybPa3b+U0gH0EULUB74XQvQMMrza3L8Q4mzgkJRyhRBiRCinmBxLyHs3MFRKuU8I0RSYJYTYFGRspd5/ImsG2UAbw35rYF+M5nI8OOhS/3C9HnIdD/Q9ZLu2fY/HPUKIZDRB8JmU8jvX4Rpz/zpSyjxgHnAmNeP+hwLnCiGy0My+I4UQn1Iz7h0AKeU+1+sh4Hs0c/hxuf9EFgbLgM5CiA5CiBTgcuCnGM+pKvkJmOTangT8aDh+uRAiVQjRAegMLHWpkwVCiMGuSIKrDefELa65fgBslFK+bHirptx/E5dGgBCiFjAa2EQNuH8p5YNSytZSyvZo/89zpJRXUQPuHUAIUVsIUUffBsYC6zhe9x9r73mUnvdxaNEm24GHYz2fSryvL4D9gA1Nyl8PNAJmA1tdrw0N4x92fQebMUQNAANcf0zbgTdwZZzH8w9wKppKuxZY7foZV4PuvzewynX/64DHXMdrxP0b5j4CTzRRjbh3tMjINa6f9foz7XjdvypHoVAoFIqENhMpFAqFopJQwkChUCgUShgoFAqFQgkDhUKhUKCEgUKhUChQwkChUCgUKGGgUCgUCuD/Abn3fmiyYNiCAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(hfq['收盘'], color='C0', label='hfq')\n",
    "plt.plot(qfq['收盘'], color='C1', label='qfq')\n",
    "plt.plot(bfq['收盘'], color='C2', label='bfq')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7a0b5c76-2c96-422b-862a-1b598bbe096c",
   "metadata": {},
   "source": [
    "### 获取后复权"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "eda7faa9-32ef-4488-a713-a8e0f5b34343",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol=\"000001\", period=\"daily\", start_date=\"20170101\", end_date='20210907', adjust=\"hfq\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "a982f2f3-5ec6-48be-94d7-7ee8a1055c20",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>收盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>换手率</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2017-01-03</td>\n",
       "      <td>1513.44</td>\n",
       "      <td>1521.56</td>\n",
       "      <td>1524.82</td>\n",
       "      <td>1510.19</td>\n",
       "      <td>459840</td>\n",
       "      <td>4.205952e+08</td>\n",
       "      <td>0.97</td>\n",
       "      <td>0.64</td>\n",
       "      <td>9.75</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2017-01-04</td>\n",
       "      <td>1519.94</td>\n",
       "      <td>1521.56</td>\n",
       "      <td>1524.82</td>\n",
       "      <td>1518.31</td>\n",
       "      <td>449330</td>\n",
       "      <td>4.115034e+08</td>\n",
       "      <td>0.43</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017-01-05</td>\n",
       "      <td>1523.19</td>\n",
       "      <td>1523.19</td>\n",
       "      <td>1524.82</td>\n",
       "      <td>1519.94</td>\n",
       "      <td>344373</td>\n",
       "      <td>3.157697e+08</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.11</td>\n",
       "      <td>1.63</td>\n",
       "      <td>0.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2017-01-06</td>\n",
       "      <td>1523.19</td>\n",
       "      <td>1516.69</td>\n",
       "      <td>1523.19</td>\n",
       "      <td>1513.44</td>\n",
       "      <td>358154</td>\n",
       "      <td>3.271764e+08</td>\n",
       "      <td>0.64</td>\n",
       "      <td>-0.43</td>\n",
       "      <td>-6.50</td>\n",
       "      <td>0.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2017-01-09</td>\n",
       "      <td>1516.69</td>\n",
       "      <td>1519.94</td>\n",
       "      <td>1523.19</td>\n",
       "      <td>1513.44</td>\n",
       "      <td>361082</td>\n",
       "      <td>3.299946e+08</td>\n",
       "      <td>0.64</td>\n",
       "      <td>0.21</td>\n",
       "      <td>3.25</td>\n",
       "      <td>0.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1136</th>\n",
       "      <td>2021-09-01</td>\n",
       "      <td>3009.83</td>\n",
       "      <td>3074.84</td>\n",
       "      <td>3081.34</td>\n",
       "      <td>2933.44</td>\n",
       "      <td>2316894</td>\n",
       "      <td>4.046284e+09</td>\n",
       "      <td>4.83</td>\n",
       "      <td>0.42</td>\n",
       "      <td>13.00</td>\n",
       "      <td>1.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1137</th>\n",
       "      <td>2021-09-02</td>\n",
       "      <td>3094.34</td>\n",
       "      <td>3159.35</td>\n",
       "      <td>3221.11</td>\n",
       "      <td>3061.84</td>\n",
       "      <td>2422604</td>\n",
       "      <td>4.454545e+09</td>\n",
       "      <td>5.18</td>\n",
       "      <td>2.75</td>\n",
       "      <td>84.51</td>\n",
       "      <td>1.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1138</th>\n",
       "      <td>2021-09-03</td>\n",
       "      <td>3175.61</td>\n",
       "      <td>3100.84</td>\n",
       "      <td>3175.61</td>\n",
       "      <td>3045.58</td>\n",
       "      <td>1394819</td>\n",
       "      <td>2.523273e+09</td>\n",
       "      <td>4.12</td>\n",
       "      <td>-1.85</td>\n",
       "      <td>-58.51</td>\n",
       "      <td>0.72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1139</th>\n",
       "      <td>2021-09-06</td>\n",
       "      <td>3082.97</td>\n",
       "      <td>3167.48</td>\n",
       "      <td>3191.86</td>\n",
       "      <td>3058.59</td>\n",
       "      <td>1515226</td>\n",
       "      <td>2.780281e+09</td>\n",
       "      <td>4.30</td>\n",
       "      <td>2.15</td>\n",
       "      <td>66.64</td>\n",
       "      <td>0.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1140</th>\n",
       "      <td>2021-09-07</td>\n",
       "      <td>3191.86</td>\n",
       "      <td>3295.88</td>\n",
       "      <td>3347.89</td>\n",
       "      <td>3151.23</td>\n",
       "      <td>1622344</td>\n",
       "      <td>3.067366e+09</td>\n",
       "      <td>6.21</td>\n",
       "      <td>4.05</td>\n",
       "      <td>128.40</td>\n",
       "      <td>0.84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1141 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              日期       开盘       收盘       最高       最低      成交量           成交额  \\\n",
       "0     2017-01-03  1513.44  1521.56  1524.82  1510.19   459840  4.205952e+08   \n",
       "1     2017-01-04  1519.94  1521.56  1524.82  1518.31   449330  4.115034e+08   \n",
       "2     2017-01-05  1523.19  1523.19  1524.82  1519.94   344373  3.157697e+08   \n",
       "3     2017-01-06  1523.19  1516.69  1523.19  1513.44   358154  3.271764e+08   \n",
       "4     2017-01-09  1516.69  1519.94  1523.19  1513.44   361082  3.299946e+08   \n",
       "...          ...      ...      ...      ...      ...      ...           ...   \n",
       "1136  2021-09-01  3009.83  3074.84  3081.34  2933.44  2316894  4.046284e+09   \n",
       "1137  2021-09-02  3094.34  3159.35  3221.11  3061.84  2422604  4.454545e+09   \n",
       "1138  2021-09-03  3175.61  3100.84  3175.61  3045.58  1394819  2.523273e+09   \n",
       "1139  2021-09-06  3082.97  3167.48  3191.86  3058.59  1515226  2.780281e+09   \n",
       "1140  2021-09-07  3191.86  3295.88  3347.89  3151.23  1622344  3.067366e+09   \n",
       "\n",
       "        振幅   涨跌幅     涨跌额   换手率  \n",
       "0     0.97  0.64    9.75  0.31  \n",
       "1     0.43  0.00    0.00  0.31  \n",
       "2     0.32  0.11    1.63  0.24  \n",
       "3     0.64 -0.43   -6.50  0.24  \n",
       "4     0.64  0.21    3.25  0.21  \n",
       "...    ...   ...     ...   ...  \n",
       "1136  4.83  0.42   13.00  1.19  \n",
       "1137  5.18  2.75   84.51  1.25  \n",
       "1138  4.12 -1.85  -58.51  0.72  \n",
       "1139  4.30  2.15   66.64  0.78  \n",
       "1140  6.21  4.05  128.40  0.84  \n",
       "\n",
       "[1141 rows x 11 columns]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_zh_a_hist_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f122e51-2639-4be3-a0aa-ad7dcd63693a",
   "metadata": {},
   "source": [
    "### 循环获取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "a4ca184d-f154-413a-a86b-719fde097a1d",
   "metadata": {},
   "outputs": [],
   "source": [
    "total_stock_list = stock_df['代码'].tolist()\n",
    "total_stock_list = total_stock_list[:1000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "f5dd3783-e328-4590-a5fa-1c7aaab7fc3b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1000"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(total_stock_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "122eef19-fbde-4f8a-a5d4-1d912fa2dfba",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_hist_dict = {}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "5190446b-b45b-45d9-a946-dd3f817cb4f5",
   "metadata": {},
   "outputs": [],
   "source": [
    "start_date  = '20170101'\n",
    "end_date = '20230131'\n",
    "adjust = 'hfq'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "4c0bf857-90ca-4220-b63e-b8c49366520a",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "has got 0 stock data, achieve 0.0, cost 0.001980304718017578\n",
      "has got 50 stock data, achieve 0.05, cost 4.331678628921509\n",
      "has got 100 stock data, achieve 0.1, cost 9.118650436401367\n",
      "has got 150 stock data, achieve 0.15, cost 13.207457065582275\n",
      "has got 200 stock data, achieve 0.2, cost 17.933401584625244\n",
      "has got 250 stock data, achieve 0.25, cost 23.21298384666443\n",
      "has got 300 stock data, achieve 0.3, cost 29.508180856704712\n",
      "has got 350 stock data, achieve 0.35, cost 34.820443630218506\n",
      "has got 400 stock data, achieve 0.4, cost 41.359251737594604\n",
      "has got 450 stock data, achieve 0.45, cost 45.60285711288452\n",
      "has got 500 stock data, achieve 0.5, cost 50.150957107543945\n",
      "has got 550 stock data, achieve 0.55, cost 54.51493191719055\n",
      "has got 600 stock data, achieve 0.6, cost 57.94046115875244\n",
      "has got 650 stock data, achieve 0.65, cost 61.853256940841675\n",
      "has got 700 stock data, achieve 0.7, cost 65.95582127571106\n",
      "has got 750 stock data, achieve 0.75, cost 69.87637305259705\n",
      "has got 800 stock data, achieve 0.8, cost 74.38798332214355\n",
      "has got 850 stock data, achieve 0.85, cost 77.90730476379395\n",
      "has got 900 stock data, achieve 0.9, cost 82.69956469535828\n",
      "has got 950 stock data, achieve 0.95, cost 86.3005006313324\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "start_time = time.time()\n",
    "# 每次从未获取成功的股票循环获取，而不是每次都重新开始\n",
    "pending_stock_list = list(set(total_stock_list) - set(stock_hist_dict))\n",
    "\n",
    "for num, stock_id in enumerate(pending_stock_list):\n",
    "    if num % 50 == 0:\n",
    "        print(f'has got {num} stock data, achieve {num/len(pending_stock_list)}, cost {time.time()-start_time}')\n",
    "    tmp_df = ak.stock_zh_a_hist(symbol=stock_id, period=\"daily\", start_date=start_date, end_date=end_date, adjust=adjust)\n",
    "    stock_hist_dict[stock_id] = tmp_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ff2da85-e78b-4e50-abbf-c6b865af3dfd",
   "metadata": {},
   "source": [
    "### 数据拼接"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "a0cf4c17-eba5-4ed1-8960-41d8d26270e7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "total_hist_df = pd.DataFrame()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "d21d29dc-2720-47bd-9d24-f6b76bd019cc",
   "metadata": {},
   "outputs": [],
   "source": [
    "for k, v in stock_hist_dict.items():\n",
    "    tmp_df = v\n",
    "    tmp_df['股票代码'] = k\n",
    "    total_hist_df = pd.concat([total_hist_df, tmp_df], axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "e86d6ee3-83f0-4a33-b508-920b2f913632",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>收盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>换手率</th>\n",
       "      <th>股票代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-02-11</td>\n",
       "      <td>70.00</td>\n",
       "      <td>85.00</td>\n",
       "      <td>113.00</td>\n",
       "      <td>69.99</td>\n",
       "      <td>138004.0</td>\n",
       "      <td>1.224828e+09</td>\n",
       "      <td>178.32</td>\n",
       "      <td>252.40</td>\n",
       "      <td>60.88</td>\n",
       "      <td>75.82</td>\n",
       "      <td>688398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-02-12</td>\n",
       "      <td>76.00</td>\n",
       "      <td>83.88</td>\n",
       "      <td>84.01</td>\n",
       "      <td>71.01</td>\n",
       "      <td>83962.0</td>\n",
       "      <td>6.409996e+08</td>\n",
       "      <td>15.29</td>\n",
       "      <td>-1.32</td>\n",
       "      <td>-1.12</td>\n",
       "      <td>46.13</td>\n",
       "      <td>688398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-02-13</td>\n",
       "      <td>79.00</td>\n",
       "      <td>75.80</td>\n",
       "      <td>79.55</td>\n",
       "      <td>74.47</td>\n",
       "      <td>61740.0</td>\n",
       "      <td>4.753326e+08</td>\n",
       "      <td>6.06</td>\n",
       "      <td>-9.63</td>\n",
       "      <td>-8.08</td>\n",
       "      <td>33.92</td>\n",
       "      <td>688398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-02-14</td>\n",
       "      <td>73.30</td>\n",
       "      <td>74.98</td>\n",
       "      <td>78.82</td>\n",
       "      <td>71.57</td>\n",
       "      <td>42036.0</td>\n",
       "      <td>3.156774e+08</td>\n",
       "      <td>9.56</td>\n",
       "      <td>-1.08</td>\n",
       "      <td>-0.82</td>\n",
       "      <td>23.10</td>\n",
       "      <td>688398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-02-17</td>\n",
       "      <td>73.95</td>\n",
       "      <td>76.53</td>\n",
       "      <td>79.52</td>\n",
       "      <td>73.17</td>\n",
       "      <td>51267.0</td>\n",
       "      <td>3.902146e+08</td>\n",
       "      <td>8.47</td>\n",
       "      <td>2.07</td>\n",
       "      <td>1.55</td>\n",
       "      <td>28.17</td>\n",
       "      <td>688398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1458</th>\n",
       "      <td>2023-01-18</td>\n",
       "      <td>129.60</td>\n",
       "      <td>131.08</td>\n",
       "      <td>131.89</td>\n",
       "      <td>128.65</td>\n",
       "      <td>153876.0</td>\n",
       "      <td>2.906024e+08</td>\n",
       "      <td>2.51</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.89</td>\n",
       "      <td>3.71</td>\n",
       "      <td>300075</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1459</th>\n",
       "      <td>2023-01-19</td>\n",
       "      <td>130.61</td>\n",
       "      <td>133.44</td>\n",
       "      <td>133.92</td>\n",
       "      <td>130.20</td>\n",
       "      <td>246781.0</td>\n",
       "      <td>4.740522e+08</td>\n",
       "      <td>2.84</td>\n",
       "      <td>1.80</td>\n",
       "      <td>2.36</td>\n",
       "      <td>5.94</td>\n",
       "      <td>300075</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1460</th>\n",
       "      <td>2023-01-20</td>\n",
       "      <td>133.44</td>\n",
       "      <td>134.46</td>\n",
       "      <td>135.81</td>\n",
       "      <td>132.09</td>\n",
       "      <td>249711.0</td>\n",
       "      <td>4.847733e+08</td>\n",
       "      <td>2.79</td>\n",
       "      <td>0.76</td>\n",
       "      <td>1.02</td>\n",
       "      <td>6.01</td>\n",
       "      <td>300075</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1461</th>\n",
       "      <td>2023-01-30</td>\n",
       "      <td>137.63</td>\n",
       "      <td>135.20</td>\n",
       "      <td>138.30</td>\n",
       "      <td>134.73</td>\n",
       "      <td>281305.0</td>\n",
       "      <td>5.534254e+08</td>\n",
       "      <td>2.66</td>\n",
       "      <td>0.55</td>\n",
       "      <td>0.74</td>\n",
       "      <td>6.78</td>\n",
       "      <td>300075</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1462</th>\n",
       "      <td>2023-01-31</td>\n",
       "      <td>134.25</td>\n",
       "      <td>134.32</td>\n",
       "      <td>135.81</td>\n",
       "      <td>133.71</td>\n",
       "      <td>172983.0</td>\n",
       "      <td>3.363900e+08</td>\n",
       "      <td>1.55</td>\n",
       "      <td>-0.65</td>\n",
       "      <td>-0.88</td>\n",
       "      <td>4.17</td>\n",
       "      <td>300075</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1072955 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              日期      开盘      收盘      最高      最低       成交量           成交额  \\\n",
       "0     2020-02-11   70.00   85.00  113.00   69.99  138004.0  1.224828e+09   \n",
       "1     2020-02-12   76.00   83.88   84.01   71.01   83962.0  6.409996e+08   \n",
       "2     2020-02-13   79.00   75.80   79.55   74.47   61740.0  4.753326e+08   \n",
       "3     2020-02-14   73.30   74.98   78.82   71.57   42036.0  3.156774e+08   \n",
       "4     2020-02-17   73.95   76.53   79.52   73.17   51267.0  3.902146e+08   \n",
       "...          ...     ...     ...     ...     ...       ...           ...   \n",
       "1458  2023-01-18  129.60  131.08  131.89  128.65  153876.0  2.906024e+08   \n",
       "1459  2023-01-19  130.61  133.44  133.92  130.20  246781.0  4.740522e+08   \n",
       "1460  2023-01-20  133.44  134.46  135.81  132.09  249711.0  4.847733e+08   \n",
       "1461  2023-01-30  137.63  135.20  138.30  134.73  281305.0  5.534254e+08   \n",
       "1462  2023-01-31  134.25  134.32  135.81  133.71  172983.0  3.363900e+08   \n",
       "\n",
       "          振幅     涨跌幅    涨跌额    换手率    股票代码  \n",
       "0     178.32  252.40  60.88  75.82  688398  \n",
       "1      15.29   -1.32  -1.12  46.13  688398  \n",
       "2       6.06   -9.63  -8.08  33.92  688398  \n",
       "3       9.56   -1.08  -0.82  23.10  688398  \n",
       "4       8.47    2.07   1.55  28.17  688398  \n",
       "...      ...     ...    ...    ...     ...  \n",
       "1458    2.51    1.46   1.89   3.71  300075  \n",
       "1459    2.84    1.80   2.36   5.94  300075  \n",
       "1460    2.79    0.76   1.02   6.01  300075  \n",
       "1461    2.66    0.55   0.74   6.78  300075  \n",
       "1462    1.55   -0.65  -0.88   4.17  300075  \n",
       "\n",
       "[1072955 rows x 12 columns]"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total_hist_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45876c7f-3a9b-47fd-894a-f42dfbfcc15b",
   "metadata": {
    "tags": []
   },
   "source": [
    "## 准备将数据存入数据库"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b7ad434-8307-4f4f-a026-8415812d09a7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 连接database\n",
    "conn = pymysql.connect(host='127.0.0.1',port=3306, user='root',password='biliafan'\n",
    "                       ,database='test'\n",
    "                       ,charset='utf8')\n",
    "# 得到一个可以执行SQL语句并且将结果作为字典返回的游标\n",
    "cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ecb80af2-8d82-4962-b017-c4f6ba22a7a8",
   "metadata": {},
   "source": [
    "### 创建数据表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d1f3164d-74f3-4f62-af78-94120388866a",
   "metadata": {},
   "source": [
    "分成2个表来存，因为数据粒度不同会带来很多问题，比如股票改名字了，此时就要去行情数据修改这些信息"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "05b1f8f1-de7d-49f2-8584-b94855481221",
   "metadata": {},
   "source": [
    "数据库规范化 - 六大范式解析：https://blog.csdn.net/weixin_48581386/article/details/125116744"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6ef530d-227b-43f7-93bc-852190542adf",
   "metadata": {},
   "source": [
    "#### 股票信息数据表"
   ]
  },
  {
   "cell_type": "raw",
   "id": "5814f740-4c8c-4422-82c2-9181dce8ffdf",
   "metadata": {},
   "source": [
    "'代码', '名称' + 日期（可能股票更名了，我们受限于这个数据源的情况，所以需要每天都存下）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "id": "91d9d490-bc3a-40e5-b328-cac2c67b6466",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 156,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 定义要执行的SQL语句\n",
    "sql = \"\"\"\n",
    "CREATE TABLE stock_info (\n",
    "id INT auto_increment PRIMARY KEY ,\n",
    "date TIMESTAMP,\n",
    "code CHAR(6) NOT NULL,\n",
    "name VARCHAR(10)\n",
    ")ENGINE=innodb DEFAULT CHARSET=utf8;\n",
    "\"\"\"\n",
    "# 先删除表\n",
    "cursor.execute(\"drop table if exists stock_info\")\n",
    "# 执行SQL语句\n",
    "cursor.execute(sql)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2fa58cd8-55eb-4a03-ba34-a6b832f13643",
   "metadata": {},
   "source": [
    "#### 股票行情数据表"
   ]
  },
  {
   "cell_type": "raw",
   "id": "2e201727-25b4-45ac-aca3-7ec5c2a1bcf6",
   "metadata": {},
   "source": [
    "日期\t股票代码\t开盘\t收盘\t最高\t最低\t成交量\t成交额"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "id": "53e1f99d-9752-41a5-9f1c-b082ddc3d1c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 定义要执行的SQL语句\n",
    "sql = \"\"\"\n",
    "CREATE TABLE stock_daybar (\n",
    "id INT auto_increment PRIMARY KEY ,\n",
    "date TIMESTAMP,\n",
    "code CHAR(6) NOT NULL,\n",
    "open FLOAT,\n",
    "high FLOAT,\n",
    "low FLOAT,\n",
    "close FLOAT,\n",
    "volume FLOAT,\n",
    "turnover FLOAT\n",
    ")ENGINE=innodb DEFAULT CHARSET=utf8;\n",
    "\"\"\"\n",
    "# 先删除表\n",
    "cursor.execute(\"drop table if exists stock_daybar\")\n",
    "# 执行SQL语句\n",
    "cursor.execute(sql)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c6d87ea5-aed9-4009-8ee4-ff64658a194e",
   "metadata": {},
   "source": [
    "### 数据插入"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf6a44d0-8d3c-458e-9f24-22d9936e0118",
   "metadata": {
    "tags": []
   },
   "source": [
    "#### 信息数据表插入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "id": "ce69d016-5f3d-4a36-9334-4e2a547f45c6",
   "metadata": {},
   "outputs": [],
   "source": [
    "info_sql = \"INSERT INTO stock_info(date, code, name) VALUES (%s, %s, %s);\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "id": "9c659992-ed80-407f-b32a-2c1fdb807428",
   "metadata": {},
   "outputs": [],
   "source": [
    "info_df = stock_df.loc[:, ['代码', '名称']]\n",
    "info_df['日期'] = end_date\n",
    "# 调整顺序的必要性\n",
    "info_df = info_df.loc[:, ['日期', '代码', '名称']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "id": "e49692e0-2e49-4b10-b26c-c4ea3c8d3c7d",
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    # 批量执行多条插入SQL语句\n",
    "    cursor.executemany(info_sql, info_df.values.tolist())\n",
    "    # 提交事务\n",
    "    conn.commit()\n",
    "except Exception as e:\n",
    "    print(e)\n",
    "    # 有异常，回滚事务\n",
    "    conn.rollback()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "819b0355-2cfb-4fe7-a26e-c192b0bb6f26",
   "metadata": {
    "tags": []
   },
   "source": [
    "#### 行情数据表插入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "6e3d51fb-8527-46db-96f6-605bb1208701",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 163,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 定义要执行的SQL语句\n",
    "sql = \"\"\"\n",
    "CREATE TABLE stock_daybar (\n",
    "id INT auto_increment PRIMARY KEY ,\n",
    "date TIMESTAMP,\n",
    "code CHAR(6) NOT NULL,\n",
    "open FLOAT,\n",
    "high FLOAT,\n",
    "low FLOAT,\n",
    "close FLOAT,\n",
    "volume FLOAT,\n",
    "turnover FLOAT\n",
    ")ENGINE=innodb DEFAULT CHARSET=utf8;\n",
    "\"\"\"\n",
    "# 先删除表\n",
    "cursor.execute(\"drop table if exists stock_daybar\")\n",
    "# 执行SQL语句\n",
    "cursor.execute(sql)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "id": "41969512-3e37-4b2f-8bfa-a51800f2d0dc",
   "metadata": {},
   "outputs": [],
   "source": [
    "daybar_sql = \"INSERT INTO stock_daybar(date, code, open, high, low, close, volume, turnover) \"\\\n",
    "             \"VALUES (%s, %s, %s, %s, %s, %s, %s, %s);\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "id": "5df3a03b-e762-4130-91ea-9bd13e0a2544",
   "metadata": {},
   "outputs": [],
   "source": [
    "daybar_df = total_hist_df.loc[:, ['日期', '股票代码', '开盘', '最高', '最低', '收盘', '成交量', '成交额']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "id": "42707525-d453-4f29-b144-53df59ce8372",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 1min 3s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "try:\n",
    "    # 批量执行多条插入SQL语句\n",
    "    cursor.executemany(daybar_sql, daybar_df.values.tolist())\n",
    "    # 提交事务\n",
    "    conn.commit()\n",
    "except Exception as e:\n",
    "    print(e)\n",
    "    # 有异常，回滚事务\n",
    "    conn.rollback()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a387879-d470-4ba9-a151-051797e7b249",
   "metadata": {},
   "source": [
    "#### 注意事项"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4339fc2a-14a2-44df-9464-dbd78a1d300b",
   "metadata": {},
   "source": [
    "np.nan"
   ]
  },
  {
   "cell_type": "raw",
   "id": "abf5f445-b8ea-4fc3-b092-870d9f61a0ac",
   "metadata": {},
   "source": [
    "nan can't be used with mysql"
   ]
  },
  {
   "cell_type": "raw",
   "id": "424de656-c685-415f-950d-0cbe3718d9b2",
   "metadata": {},
   "source": [
    "#保留非空值，以None空值的形式替换Nan空值\n",
    "df = df.where(df.notnull(), None)\n",
    " \n",
    "#取值，以np.ndarry的形式转为列表\n",
    "data = df.values.tolist()"
   ]
  },
  {
   "cell_type": "raw",
   "id": "b98761a1-e56f-4e9d-a3ea-b38b61151444",
   "metadata": {},
   "source": [
    "mysql不支持无穷大np.inf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "id": "7ac8f9d7-69e4-4c95-ab0a-cd4d5fda366f",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"select count(*) from stock_daybar\"  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "id": "67628099-ef12-4959-8a09-b79486361a2f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 76.8 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[{'count(*)': 1073955}]"
      ]
     },
     "execution_count": 194,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "cursor.execute(sql)\n",
    "results = cursor.fetchall()\n",
    "results"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0bd9d942-3e66-4ad9-ab95-b8805763c3a9",
   "metadata": {},
   "source": [
    "### 数据查询"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a62de7a-cc9a-4584-9697-e2bec4b3cb4e",
   "metadata": {},
   "source": [
    "pandas+pymyql使用原则：先用sql进行必要的筛选过滤，再用pandas处理，如果数据量不大，直接全量读取"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c8acc78-6068-4417-8f6a-ee34837e8020",
   "metadata": {},
   "source": [
    "#### 全量行情查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "id": "6ab1d25f-3eb7-47dd-888c-e3dca9003691",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"select * from stock_daybar\"  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "id": "00fe6097-0ebb-46a3-8c71-e05ec76382be",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 52.2 s\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>date</th>\n",
       "      <th>code</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>volume</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2020-02-11</td>\n",
       "      <td>688398</td>\n",
       "      <td>70.00</td>\n",
       "      <td>113.00</td>\n",
       "      <td>69.99</td>\n",
       "      <td>85.00</td>\n",
       "      <td>138004.0</td>\n",
       "      <td>1.224830e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2020-02-12</td>\n",
       "      <td>688398</td>\n",
       "      <td>76.00</td>\n",
       "      <td>84.01</td>\n",
       "      <td>71.01</td>\n",
       "      <td>83.88</td>\n",
       "      <td>83962.0</td>\n",
       "      <td>6.410000e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2020-02-13</td>\n",
       "      <td>688398</td>\n",
       "      <td>79.00</td>\n",
       "      <td>79.55</td>\n",
       "      <td>74.47</td>\n",
       "      <td>75.80</td>\n",
       "      <td>61740.0</td>\n",
       "      <td>4.753330e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2020-02-14</td>\n",
       "      <td>688398</td>\n",
       "      <td>73.30</td>\n",
       "      <td>78.82</td>\n",
       "      <td>71.57</td>\n",
       "      <td>74.98</td>\n",
       "      <td>42036.0</td>\n",
       "      <td>3.156770e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2020-02-17</td>\n",
       "      <td>688398</td>\n",
       "      <td>73.95</td>\n",
       "      <td>79.52</td>\n",
       "      <td>73.17</td>\n",
       "      <td>76.53</td>\n",
       "      <td>51267.0</td>\n",
       "      <td>3.902150e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072950</th>\n",
       "      <td>1072951</td>\n",
       "      <td>2023-01-18</td>\n",
       "      <td>300075</td>\n",
       "      <td>129.60</td>\n",
       "      <td>131.89</td>\n",
       "      <td>128.65</td>\n",
       "      <td>131.08</td>\n",
       "      <td>153876.0</td>\n",
       "      <td>2.906020e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072951</th>\n",
       "      <td>1072952</td>\n",
       "      <td>2023-01-19</td>\n",
       "      <td>300075</td>\n",
       "      <td>130.61</td>\n",
       "      <td>133.92</td>\n",
       "      <td>130.20</td>\n",
       "      <td>133.44</td>\n",
       "      <td>246781.0</td>\n",
       "      <td>4.740520e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072952</th>\n",
       "      <td>1072953</td>\n",
       "      <td>2023-01-20</td>\n",
       "      <td>300075</td>\n",
       "      <td>133.44</td>\n",
       "      <td>135.81</td>\n",
       "      <td>132.09</td>\n",
       "      <td>134.46</td>\n",
       "      <td>249711.0</td>\n",
       "      <td>4.847730e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072953</th>\n",
       "      <td>1072954</td>\n",
       "      <td>2023-01-30</td>\n",
       "      <td>300075</td>\n",
       "      <td>137.63</td>\n",
       "      <td>138.30</td>\n",
       "      <td>134.73</td>\n",
       "      <td>135.20</td>\n",
       "      <td>281305.0</td>\n",
       "      <td>5.534250e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072954</th>\n",
       "      <td>1072955</td>\n",
       "      <td>2023-01-31</td>\n",
       "      <td>300075</td>\n",
       "      <td>134.25</td>\n",
       "      <td>135.81</td>\n",
       "      <td>133.71</td>\n",
       "      <td>134.32</td>\n",
       "      <td>172983.0</td>\n",
       "      <td>3.363900e+08</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1072955 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              id       date    code    open    high     low   close    volume  \\\n",
       "0              1 2020-02-11  688398   70.00  113.00   69.99   85.00  138004.0   \n",
       "1              2 2020-02-12  688398   76.00   84.01   71.01   83.88   83962.0   \n",
       "2              3 2020-02-13  688398   79.00   79.55   74.47   75.80   61740.0   \n",
       "3              4 2020-02-14  688398   73.30   78.82   71.57   74.98   42036.0   \n",
       "4              5 2020-02-17  688398   73.95   79.52   73.17   76.53   51267.0   \n",
       "...          ...        ...     ...     ...     ...     ...     ...       ...   \n",
       "1072950  1072951 2023-01-18  300075  129.60  131.89  128.65  131.08  153876.0   \n",
       "1072951  1072952 2023-01-19  300075  130.61  133.92  130.20  133.44  246781.0   \n",
       "1072952  1072953 2023-01-20  300075  133.44  135.81  132.09  134.46  249711.0   \n",
       "1072953  1072954 2023-01-30  300075  137.63  138.30  134.73  135.20  281305.0   \n",
       "1072954  1072955 2023-01-31  300075  134.25  135.81  133.71  134.32  172983.0   \n",
       "\n",
       "             turnover  \n",
       "0        1.224830e+09  \n",
       "1        6.410000e+08  \n",
       "2        4.753330e+08  \n",
       "3        3.156770e+08  \n",
       "4        3.902150e+08  \n",
       "...               ...  \n",
       "1072950  2.906020e+08  \n",
       "1072951  4.740520e+08  \n",
       "1072952  4.847730e+08  \n",
       "1072953  5.534250e+08  \n",
       "1072954  3.363900e+08  \n",
       "\n",
       "[1072955 rows x 9 columns]"
      ]
     },
     "execution_count": 171,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "cursor.execute(sql)\n",
    "results = cursor.fetchall()\n",
    "daybar_df = pd.DataFrame(results)\n",
    "daybar_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c243f521-021b-484e-9022-38d20e29ca51",
   "metadata": {},
   "source": [
    "#### 指定字段查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "id": "b31fdcf1-d7ef-4a4f-a01e-eaba6960d107",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"select date, code, close from stock_daybar\"  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "id": "ff9a3368-cba6-4e01-955b-9360824b1d06",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 38.7 s\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>code</th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-02-11</td>\n",
       "      <td>688398</td>\n",
       "      <td>85.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-02-12</td>\n",
       "      <td>688398</td>\n",
       "      <td>83.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-02-13</td>\n",
       "      <td>688398</td>\n",
       "      <td>75.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-02-14</td>\n",
       "      <td>688398</td>\n",
       "      <td>74.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-02-17</td>\n",
       "      <td>688398</td>\n",
       "      <td>76.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072950</th>\n",
       "      <td>2023-01-18</td>\n",
       "      <td>300075</td>\n",
       "      <td>131.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072951</th>\n",
       "      <td>2023-01-19</td>\n",
       "      <td>300075</td>\n",
       "      <td>133.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072952</th>\n",
       "      <td>2023-01-20</td>\n",
       "      <td>300075</td>\n",
       "      <td>134.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072953</th>\n",
       "      <td>2023-01-30</td>\n",
       "      <td>300075</td>\n",
       "      <td>135.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1072954</th>\n",
       "      <td>2023-01-31</td>\n",
       "      <td>300075</td>\n",
       "      <td>134.32</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1072955 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              date    code   close\n",
       "0       2020-02-11  688398   85.00\n",
       "1       2020-02-12  688398   83.88\n",
       "2       2020-02-13  688398   75.80\n",
       "3       2020-02-14  688398   74.98\n",
       "4       2020-02-17  688398   76.53\n",
       "...            ...     ...     ...\n",
       "1072950 2023-01-18  300075  131.08\n",
       "1072951 2023-01-19  300075  133.44\n",
       "1072952 2023-01-20  300075  134.46\n",
       "1072953 2023-01-30  300075  135.20\n",
       "1072954 2023-01-31  300075  134.32\n",
       "\n",
       "[1072955 rows x 3 columns]"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "cursor.execute(sql)\n",
    "results = cursor.fetchall()\n",
    "daybar_df = pd.DataFrame(results)\n",
    "daybar_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "22ad6ffd-ba92-47a5-982a-3d3403738a33",
   "metadata": {},
   "source": [
    "#### 个股行情查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "id": "37c7ba9d-0f06-4cea-806b-1c1e0f6f7bc9",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"select * from stock_daybar where code = '688398'\"  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "id": "bc6fe8cf-8001-4f36-ad1d-22a38082eb91",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 673 ms\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>date</th>\n",
       "      <th>code</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>volume</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2020-02-11</td>\n",
       "      <td>688398</td>\n",
       "      <td>70.00</td>\n",
       "      <td>113.00</td>\n",
       "      <td>69.99</td>\n",
       "      <td>85.00</td>\n",
       "      <td>138004.0</td>\n",
       "      <td>1.224830e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2020-02-12</td>\n",
       "      <td>688398</td>\n",
       "      <td>76.00</td>\n",
       "      <td>84.01</td>\n",
       "      <td>71.01</td>\n",
       "      <td>83.88</td>\n",
       "      <td>83962.0</td>\n",
       "      <td>6.410000e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2020-02-13</td>\n",
       "      <td>688398</td>\n",
       "      <td>79.00</td>\n",
       "      <td>79.55</td>\n",
       "      <td>74.47</td>\n",
       "      <td>75.80</td>\n",
       "      <td>61740.0</td>\n",
       "      <td>4.753330e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2020-02-14</td>\n",
       "      <td>688398</td>\n",
       "      <td>73.30</td>\n",
       "      <td>78.82</td>\n",
       "      <td>71.57</td>\n",
       "      <td>74.98</td>\n",
       "      <td>42036.0</td>\n",
       "      <td>3.156770e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2020-02-17</td>\n",
       "      <td>688398</td>\n",
       "      <td>73.95</td>\n",
       "      <td>79.52</td>\n",
       "      <td>73.17</td>\n",
       "      <td>76.53</td>\n",
       "      <td>51267.0</td>\n",
       "      <td>3.902150e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>718</th>\n",
       "      <td>719</td>\n",
       "      <td>2023-01-19</td>\n",
       "      <td>688398</td>\n",
       "      <td>39.19</td>\n",
       "      <td>41.50</td>\n",
       "      <td>38.89</td>\n",
       "      <td>41.04</td>\n",
       "      <td>9576.0</td>\n",
       "      <td>3.783160e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>719</th>\n",
       "      <td>720</td>\n",
       "      <td>2023-01-20</td>\n",
       "      <td>688398</td>\n",
       "      <td>40.84</td>\n",
       "      <td>41.31</td>\n",
       "      <td>39.91</td>\n",
       "      <td>40.59</td>\n",
       "      <td>4188.0</td>\n",
       "      <td>1.642230e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>720</th>\n",
       "      <td>721</td>\n",
       "      <td>2023-01-30</td>\n",
       "      <td>688398</td>\n",
       "      <td>40.59</td>\n",
       "      <td>40.96</td>\n",
       "      <td>39.80</td>\n",
       "      <td>40.58</td>\n",
       "      <td>6124.0</td>\n",
       "      <td>2.400520e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>721</th>\n",
       "      <td>722</td>\n",
       "      <td>2023-01-31</td>\n",
       "      <td>688398</td>\n",
       "      <td>40.19</td>\n",
       "      <td>41.61</td>\n",
       "      <td>39.91</td>\n",
       "      <td>40.69</td>\n",
       "      <td>6712.0</td>\n",
       "      <td>2.654510e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>722</th>\n",
       "      <td>1072956</td>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>688398</td>\n",
       "      <td>40.24</td>\n",
       "      <td>44.06</td>\n",
       "      <td>40.24</td>\n",
       "      <td>43.11</td>\n",
       "      <td>18456.0</td>\n",
       "      <td>7.651670e+07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>723 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          id       date    code   open    high    low  close    volume  \\\n",
       "0          1 2020-02-11  688398  70.00  113.00  69.99  85.00  138004.0   \n",
       "1          2 2020-02-12  688398  76.00   84.01  71.01  83.88   83962.0   \n",
       "2          3 2020-02-13  688398  79.00   79.55  74.47  75.80   61740.0   \n",
       "3          4 2020-02-14  688398  73.30   78.82  71.57  74.98   42036.0   \n",
       "4          5 2020-02-17  688398  73.95   79.52  73.17  76.53   51267.0   \n",
       "..       ...        ...     ...    ...     ...    ...    ...       ...   \n",
       "718      719 2023-01-19  688398  39.19   41.50  38.89  41.04    9576.0   \n",
       "719      720 2023-01-20  688398  40.84   41.31  39.91  40.59    4188.0   \n",
       "720      721 2023-01-30  688398  40.59   40.96  39.80  40.58    6124.0   \n",
       "721      722 2023-01-31  688398  40.19   41.61  39.91  40.69    6712.0   \n",
       "722  1072956 2023-02-01  688398  40.24   44.06  40.24  43.11   18456.0   \n",
       "\n",
       "         turnover  \n",
       "0    1.224830e+09  \n",
       "1    6.410000e+08  \n",
       "2    4.753330e+08  \n",
       "3    3.156770e+08  \n",
       "4    3.902150e+08  \n",
       "..            ...  \n",
       "718  3.783160e+07  \n",
       "719  1.642230e+07  \n",
       "720  2.400520e+07  \n",
       "721  2.654510e+07  \n",
       "722  7.651670e+07  \n",
       "\n",
       "[723 rows x 9 columns]"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "cursor.execute(sql)\n",
    "results = cursor.fetchall()\n",
    "daybar_df = pd.DataFrame(results)\n",
    "daybar_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a73e40d-dfb8-4038-abf3-c9b843b95193",
   "metadata": {},
   "source": [
    "#### 指定时间查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "id": "a8cf3b38-67a3-4f7a-b57c-602d0850444f",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"select * from stock_daybar where date between '2020-01-01' and '2020-02-01'\"  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "id": "b468fdce-fcec-4747-9bc9-7e50ed741581",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 2 s\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>date</th>\n",
       "      <th>code</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>volume</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2025</td>\n",
       "      <td>2020-01-02</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.61</td>\n",
       "      <td>29.55</td>\n",
       "      <td>28.54</td>\n",
       "      <td>28.99</td>\n",
       "      <td>486187.0</td>\n",
       "      <td>313590000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2026</td>\n",
       "      <td>2020-01-03</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.91</td>\n",
       "      <td>29.02</td>\n",
       "      <td>28.61</td>\n",
       "      <td>28.69</td>\n",
       "      <td>210796.0</td>\n",
       "      <td>134119000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2027</td>\n",
       "      <td>2020-01-06</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.46</td>\n",
       "      <td>29.21</td>\n",
       "      <td>28.16</td>\n",
       "      <td>28.39</td>\n",
       "      <td>432338.0</td>\n",
       "      <td>273431000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2028</td>\n",
       "      <td>2020-01-07</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.54</td>\n",
       "      <td>28.69</td>\n",
       "      <td>28.12</td>\n",
       "      <td>28.50</td>\n",
       "      <td>215351.0</td>\n",
       "      <td>135055000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2029</td>\n",
       "      <td>2020-01-08</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.50</td>\n",
       "      <td>28.50</td>\n",
       "      <td>27.64</td>\n",
       "      <td>27.90</td>\n",
       "      <td>341186.0</td>\n",
       "      <td>209613000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11150</th>\n",
       "      <td>1072223</td>\n",
       "      <td>2020-01-17</td>\n",
       "      <td>300075</td>\n",
       "      <td>87.58</td>\n",
       "      <td>92.10</td>\n",
       "      <td>86.36</td>\n",
       "      <td>88.39</td>\n",
       "      <td>329839.0</td>\n",
       "      <td>422398000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11151</th>\n",
       "      <td>1072224</td>\n",
       "      <td>2020-01-20</td>\n",
       "      <td>300075</td>\n",
       "      <td>88.05</td>\n",
       "      <td>93.58</td>\n",
       "      <td>86.97</td>\n",
       "      <td>91.83</td>\n",
       "      <td>267441.0</td>\n",
       "      <td>349708000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11152</th>\n",
       "      <td>1072225</td>\n",
       "      <td>2020-01-21</td>\n",
       "      <td>300075</td>\n",
       "      <td>90.88</td>\n",
       "      <td>91.90</td>\n",
       "      <td>88.52</td>\n",
       "      <td>88.52</td>\n",
       "      <td>172002.0</td>\n",
       "      <td>221394000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11153</th>\n",
       "      <td>1072226</td>\n",
       "      <td>2020-01-22</td>\n",
       "      <td>300075</td>\n",
       "      <td>87.58</td>\n",
       "      <td>88.05</td>\n",
       "      <td>84.47</td>\n",
       "      <td>87.04</td>\n",
       "      <td>166022.0</td>\n",
       "      <td>206107000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11154</th>\n",
       "      <td>1072227</td>\n",
       "      <td>2020-01-23</td>\n",
       "      <td>300075</td>\n",
       "      <td>86.16</td>\n",
       "      <td>88.39</td>\n",
       "      <td>83.46</td>\n",
       "      <td>84.07</td>\n",
       "      <td>149025.0</td>\n",
       "      <td>184476000.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>11155 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            id       date    code   open   high    low  close    volume  \\\n",
       "0         2025 2020-01-02  600409  28.61  29.55  28.54  28.99  486187.0   \n",
       "1         2026 2020-01-03  600409  28.91  29.02  28.61  28.69  210796.0   \n",
       "2         2027 2020-01-06  600409  28.46  29.21  28.16  28.39  432338.0   \n",
       "3         2028 2020-01-07  600409  28.54  28.69  28.12  28.50  215351.0   \n",
       "4         2029 2020-01-08  600409  28.50  28.50  27.64  27.90  341186.0   \n",
       "...        ...        ...     ...    ...    ...    ...    ...       ...   \n",
       "11150  1072223 2020-01-17  300075  87.58  92.10  86.36  88.39  329839.0   \n",
       "11151  1072224 2020-01-20  300075  88.05  93.58  86.97  91.83  267441.0   \n",
       "11152  1072225 2020-01-21  300075  90.88  91.90  88.52  88.52  172002.0   \n",
       "11153  1072226 2020-01-22  300075  87.58  88.05  84.47  87.04  166022.0   \n",
       "11154  1072227 2020-01-23  300075  86.16  88.39  83.46  84.07  149025.0   \n",
       "\n",
       "          turnover  \n",
       "0      313590000.0  \n",
       "1      134119000.0  \n",
       "2      273431000.0  \n",
       "3      135055000.0  \n",
       "4      209613000.0  \n",
       "...            ...  \n",
       "11150  422398000.0  \n",
       "11151  349708000.0  \n",
       "11152  221394000.0  \n",
       "11153  206107000.0  \n",
       "11154  184476000.0  \n",
       "\n",
       "[11155 rows x 9 columns]"
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "cursor.execute(sql)\n",
    "results = cursor.fetchall()\n",
    "daybar_df = pd.DataFrame(results)\n",
    "daybar_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40e55528-f76e-4323-a2eb-d12f57563638",
   "metadata": {},
   "source": [
    "#### 多个股票查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "id": "f37f006a-97da-42ae-a774-4642aaa0861d",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"select * from stock_daybar where code in ('300075', '600409') and date between '2020-01-01' and '2020-02-01'\"  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 181,
   "id": "84801644-1b4e-4bdf-ba48-3808ff2f0d46",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 671 ms\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>date</th>\n",
       "      <th>code</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>volume</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2025</td>\n",
       "      <td>2020-01-02</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.61</td>\n",
       "      <td>29.55</td>\n",
       "      <td>28.54</td>\n",
       "      <td>28.99</td>\n",
       "      <td>486187.0</td>\n",
       "      <td>313590000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2026</td>\n",
       "      <td>2020-01-03</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.91</td>\n",
       "      <td>29.02</td>\n",
       "      <td>28.61</td>\n",
       "      <td>28.69</td>\n",
       "      <td>210796.0</td>\n",
       "      <td>134119000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2027</td>\n",
       "      <td>2020-01-06</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.46</td>\n",
       "      <td>29.21</td>\n",
       "      <td>28.16</td>\n",
       "      <td>28.39</td>\n",
       "      <td>432338.0</td>\n",
       "      <td>273431000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2028</td>\n",
       "      <td>2020-01-07</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.54</td>\n",
       "      <td>28.69</td>\n",
       "      <td>28.12</td>\n",
       "      <td>28.50</td>\n",
       "      <td>215351.0</td>\n",
       "      <td>135055000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2029</td>\n",
       "      <td>2020-01-08</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.50</td>\n",
       "      <td>28.50</td>\n",
       "      <td>27.64</td>\n",
       "      <td>27.90</td>\n",
       "      <td>341186.0</td>\n",
       "      <td>209613000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2030</td>\n",
       "      <td>2020-01-09</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.09</td>\n",
       "      <td>28.31</td>\n",
       "      <td>27.94</td>\n",
       "      <td>28.09</td>\n",
       "      <td>195873.0</td>\n",
       "      <td>121020000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2031</td>\n",
       "      <td>2020-01-10</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.20</td>\n",
       "      <td>28.69</td>\n",
       "      <td>28.12</td>\n",
       "      <td>28.46</td>\n",
       "      <td>256416.0</td>\n",
       "      <td>160497000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2032</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.46</td>\n",
       "      <td>28.50</td>\n",
       "      <td>28.01</td>\n",
       "      <td>28.42</td>\n",
       "      <td>201148.0</td>\n",
       "      <td>125006000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2033</td>\n",
       "      <td>2020-01-14</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.42</td>\n",
       "      <td>28.72</td>\n",
       "      <td>28.20</td>\n",
       "      <td>28.39</td>\n",
       "      <td>203376.0</td>\n",
       "      <td>127459000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2034</td>\n",
       "      <td>2020-01-15</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.39</td>\n",
       "      <td>29.29</td>\n",
       "      <td>28.20</td>\n",
       "      <td>29.21</td>\n",
       "      <td>357703.0</td>\n",
       "      <td>227412000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2035</td>\n",
       "      <td>2020-01-16</td>\n",
       "      <td>600409</td>\n",
       "      <td>29.10</td>\n",
       "      <td>29.51</td>\n",
       "      <td>28.87</td>\n",
       "      <td>29.25</td>\n",
       "      <td>257126.0</td>\n",
       "      <td>166872000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2036</td>\n",
       "      <td>2020-01-17</td>\n",
       "      <td>600409</td>\n",
       "      <td>29.32</td>\n",
       "      <td>29.40</td>\n",
       "      <td>28.61</td>\n",
       "      <td>28.72</td>\n",
       "      <td>174994.0</td>\n",
       "      <td>111780000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2037</td>\n",
       "      <td>2020-01-20</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.20</td>\n",
       "      <td>29.14</td>\n",
       "      <td>28.20</td>\n",
       "      <td>29.06</td>\n",
       "      <td>187812.0</td>\n",
       "      <td>118987000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2038</td>\n",
       "      <td>2020-01-21</td>\n",
       "      <td>600409</td>\n",
       "      <td>29.10</td>\n",
       "      <td>29.17</td>\n",
       "      <td>28.54</td>\n",
       "      <td>28.61</td>\n",
       "      <td>147197.0</td>\n",
       "      <td>93668000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2039</td>\n",
       "      <td>2020-01-22</td>\n",
       "      <td>600409</td>\n",
       "      <td>28.39</td>\n",
       "      <td>28.57</td>\n",
       "      <td>27.90</td>\n",
       "      <td>27.90</td>\n",
       "      <td>331258.0</td>\n",
       "      <td>204932000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2040</td>\n",
       "      <td>2020-01-23</td>\n",
       "      <td>600409</td>\n",
       "      <td>27.86</td>\n",
       "      <td>27.86</td>\n",
       "      <td>25.69</td>\n",
       "      <td>26.85</td>\n",
       "      <td>671354.0</td>\n",
       "      <td>385231000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1072212</td>\n",
       "      <td>2020-01-02</td>\n",
       "      <td>300075</td>\n",
       "      <td>79.75</td>\n",
       "      <td>81.30</td>\n",
       "      <td>79.75</td>\n",
       "      <td>81.03</td>\n",
       "      <td>90040.0</td>\n",
       "      <td>104387000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1072213</td>\n",
       "      <td>2020-01-03</td>\n",
       "      <td>300075</td>\n",
       "      <td>81.10</td>\n",
       "      <td>82.31</td>\n",
       "      <td>80.76</td>\n",
       "      <td>81.97</td>\n",
       "      <td>84836.0</td>\n",
       "      <td>99454400.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1072214</td>\n",
       "      <td>2020-01-06</td>\n",
       "      <td>300075</td>\n",
       "      <td>82.04</td>\n",
       "      <td>83.59</td>\n",
       "      <td>81.23</td>\n",
       "      <td>82.78</td>\n",
       "      <td>139423.0</td>\n",
       "      <td>165255000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>1072215</td>\n",
       "      <td>2020-01-07</td>\n",
       "      <td>300075</td>\n",
       "      <td>82.65</td>\n",
       "      <td>83.80</td>\n",
       "      <td>82.11</td>\n",
       "      <td>83.66</td>\n",
       "      <td>123555.0</td>\n",
       "      <td>147775000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1072216</td>\n",
       "      <td>2020-01-08</td>\n",
       "      <td>300075</td>\n",
       "      <td>83.05</td>\n",
       "      <td>83.53</td>\n",
       "      <td>81.43</td>\n",
       "      <td>81.77</td>\n",
       "      <td>140244.0</td>\n",
       "      <td>166380000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1072217</td>\n",
       "      <td>2020-01-09</td>\n",
       "      <td>300075</td>\n",
       "      <td>82.65</td>\n",
       "      <td>85.28</td>\n",
       "      <td>82.65</td>\n",
       "      <td>85.15</td>\n",
       "      <td>180412.0</td>\n",
       "      <td>218591000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1072218</td>\n",
       "      <td>2020-01-10</td>\n",
       "      <td>300075</td>\n",
       "      <td>85.48</td>\n",
       "      <td>86.02</td>\n",
       "      <td>83.66</td>\n",
       "      <td>84.34</td>\n",
       "      <td>100171.0</td>\n",
       "      <td>121649000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>1072219</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>300075</td>\n",
       "      <td>83.53</td>\n",
       "      <td>85.28</td>\n",
       "      <td>82.92</td>\n",
       "      <td>85.28</td>\n",
       "      <td>104258.0</td>\n",
       "      <td>126358000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>1072220</td>\n",
       "      <td>2020-01-14</td>\n",
       "      <td>300075</td>\n",
       "      <td>85.62</td>\n",
       "      <td>85.62</td>\n",
       "      <td>83.73</td>\n",
       "      <td>83.93</td>\n",
       "      <td>94141.0</td>\n",
       "      <td>114213000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>1072221</td>\n",
       "      <td>2020-01-15</td>\n",
       "      <td>300075</td>\n",
       "      <td>83.93</td>\n",
       "      <td>85.35</td>\n",
       "      <td>83.19</td>\n",
       "      <td>84.88</td>\n",
       "      <td>111247.0</td>\n",
       "      <td>134875000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1072222</td>\n",
       "      <td>2020-01-16</td>\n",
       "      <td>300075</td>\n",
       "      <td>84.67</td>\n",
       "      <td>85.35</td>\n",
       "      <td>83.80</td>\n",
       "      <td>84.40</td>\n",
       "      <td>82580.0</td>\n",
       "      <td>100436000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>1072223</td>\n",
       "      <td>2020-01-17</td>\n",
       "      <td>300075</td>\n",
       "      <td>87.58</td>\n",
       "      <td>92.10</td>\n",
       "      <td>86.36</td>\n",
       "      <td>88.39</td>\n",
       "      <td>329839.0</td>\n",
       "      <td>422398000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1072224</td>\n",
       "      <td>2020-01-20</td>\n",
       "      <td>300075</td>\n",
       "      <td>88.05</td>\n",
       "      <td>93.58</td>\n",
       "      <td>86.97</td>\n",
       "      <td>91.83</td>\n",
       "      <td>267441.0</td>\n",
       "      <td>349708000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1072225</td>\n",
       "      <td>2020-01-21</td>\n",
       "      <td>300075</td>\n",
       "      <td>90.88</td>\n",
       "      <td>91.90</td>\n",
       "      <td>88.52</td>\n",
       "      <td>88.52</td>\n",
       "      <td>172002.0</td>\n",
       "      <td>221394000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>1072226</td>\n",
       "      <td>2020-01-22</td>\n",
       "      <td>300075</td>\n",
       "      <td>87.58</td>\n",
       "      <td>88.05</td>\n",
       "      <td>84.47</td>\n",
       "      <td>87.04</td>\n",
       "      <td>166022.0</td>\n",
       "      <td>206107000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1072227</td>\n",
       "      <td>2020-01-23</td>\n",
       "      <td>300075</td>\n",
       "      <td>86.16</td>\n",
       "      <td>88.39</td>\n",
       "      <td>83.46</td>\n",
       "      <td>84.07</td>\n",
       "      <td>149025.0</td>\n",
       "      <td>184476000.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         id       date    code   open   high    low  close    volume  \\\n",
       "0      2025 2020-01-02  600409  28.61  29.55  28.54  28.99  486187.0   \n",
       "1      2026 2020-01-03  600409  28.91  29.02  28.61  28.69  210796.0   \n",
       "2      2027 2020-01-06  600409  28.46  29.21  28.16  28.39  432338.0   \n",
       "3      2028 2020-01-07  600409  28.54  28.69  28.12  28.50  215351.0   \n",
       "4      2029 2020-01-08  600409  28.50  28.50  27.64  27.90  341186.0   \n",
       "5      2030 2020-01-09  600409  28.09  28.31  27.94  28.09  195873.0   \n",
       "6      2031 2020-01-10  600409  28.20  28.69  28.12  28.46  256416.0   \n",
       "7      2032 2020-01-13  600409  28.46  28.50  28.01  28.42  201148.0   \n",
       "8      2033 2020-01-14  600409  28.42  28.72  28.20  28.39  203376.0   \n",
       "9      2034 2020-01-15  600409  28.39  29.29  28.20  29.21  357703.0   \n",
       "10     2035 2020-01-16  600409  29.10  29.51  28.87  29.25  257126.0   \n",
       "11     2036 2020-01-17  600409  29.32  29.40  28.61  28.72  174994.0   \n",
       "12     2037 2020-01-20  600409  28.20  29.14  28.20  29.06  187812.0   \n",
       "13     2038 2020-01-21  600409  29.10  29.17  28.54  28.61  147197.0   \n",
       "14     2039 2020-01-22  600409  28.39  28.57  27.90  27.90  331258.0   \n",
       "15     2040 2020-01-23  600409  27.86  27.86  25.69  26.85  671354.0   \n",
       "16  1072212 2020-01-02  300075  79.75  81.30  79.75  81.03   90040.0   \n",
       "17  1072213 2020-01-03  300075  81.10  82.31  80.76  81.97   84836.0   \n",
       "18  1072214 2020-01-06  300075  82.04  83.59  81.23  82.78  139423.0   \n",
       "19  1072215 2020-01-07  300075  82.65  83.80  82.11  83.66  123555.0   \n",
       "20  1072216 2020-01-08  300075  83.05  83.53  81.43  81.77  140244.0   \n",
       "21  1072217 2020-01-09  300075  82.65  85.28  82.65  85.15  180412.0   \n",
       "22  1072218 2020-01-10  300075  85.48  86.02  83.66  84.34  100171.0   \n",
       "23  1072219 2020-01-13  300075  83.53  85.28  82.92  85.28  104258.0   \n",
       "24  1072220 2020-01-14  300075  85.62  85.62  83.73  83.93   94141.0   \n",
       "25  1072221 2020-01-15  300075  83.93  85.35  83.19  84.88  111247.0   \n",
       "26  1072222 2020-01-16  300075  84.67  85.35  83.80  84.40   82580.0   \n",
       "27  1072223 2020-01-17  300075  87.58  92.10  86.36  88.39  329839.0   \n",
       "28  1072224 2020-01-20  300075  88.05  93.58  86.97  91.83  267441.0   \n",
       "29  1072225 2020-01-21  300075  90.88  91.90  88.52  88.52  172002.0   \n",
       "30  1072226 2020-01-22  300075  87.58  88.05  84.47  87.04  166022.0   \n",
       "31  1072227 2020-01-23  300075  86.16  88.39  83.46  84.07  149025.0   \n",
       "\n",
       "       turnover  \n",
       "0   313590000.0  \n",
       "1   134119000.0  \n",
       "2   273431000.0  \n",
       "3   135055000.0  \n",
       "4   209613000.0  \n",
       "5   121020000.0  \n",
       "6   160497000.0  \n",
       "7   125006000.0  \n",
       "8   127459000.0  \n",
       "9   227412000.0  \n",
       "10  166872000.0  \n",
       "11  111780000.0  \n",
       "12  118987000.0  \n",
       "13   93668000.0  \n",
       "14  204932000.0  \n",
       "15  385231000.0  \n",
       "16  104387000.0  \n",
       "17   99454400.0  \n",
       "18  165255000.0  \n",
       "19  147775000.0  \n",
       "20  166380000.0  \n",
       "21  218591000.0  \n",
       "22  121649000.0  \n",
       "23  126358000.0  \n",
       "24  114213000.0  \n",
       "25  134875000.0  \n",
       "26  100436000.0  \n",
       "27  422398000.0  \n",
       "28  349708000.0  \n",
       "29  221394000.0  \n",
       "30  206107000.0  \n",
       "31  184476000.0  "
      ]
     },
     "execution_count": 181,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%time\n",
    "cursor.execute(sql)\n",
    "results = cursor.fetchall()\n",
    "daybar_df = pd.DataFrame(results)\n",
    "daybar_df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "804264bf-28b4-462d-8996-e6a26627a586",
   "metadata": {},
   "source": [
    "### 增量更新"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1fda12f1-7e0b-4ba2-a4d3-8be5825c8371",
   "metadata": {},
   "source": [
    "#### 只演示行情更新"
   ]
  },
  {
   "cell_type": "raw",
   "id": "e2c9ecfd-41d2-4f93-8c68-adb51b7fee8f",
   "metadata": {},
   "source": [
    "total_stock_list = stock_df['代码'].tolist()\n",
    "total_stock_list = total_stock_list[:1000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "id": "147419ec-4545-4d7a-9eb3-d68ba958f3ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1000"
      ]
     },
     "execution_count": 183,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(total_stock_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "id": "9bef285f-332b-43c9-9e76-88d1e52222f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_hist_dict = {}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "id": "e1e89bd0-034b-4ae4-82c2-c1cae799b358",
   "metadata": {},
   "outputs": [],
   "source": [
    "start_date  = '20230201'\n",
    "end_date = '20230201'\n",
    "adjust = 'hfq'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "id": "2d297caa-a376-4dd4-b9f4-ce675af72ba6",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "has got 0 stock data, achieve 0.0, cost 0.002952098846435547\n",
      "has got 50 stock data, achieve 0.05, cost 1.8472812175750732\n",
      "has got 100 stock data, achieve 0.1, cost 3.4472837448120117\n",
      "has got 150 stock data, achieve 0.15, cost 4.924777984619141\n",
      "has got 200 stock data, achieve 0.2, cost 6.734432697296143\n",
      "has got 250 stock data, achieve 0.25, cost 8.391234636306763\n",
      "has got 300 stock data, achieve 0.3, cost 9.982568740844727\n",
      "has got 350 stock data, achieve 0.35, cost 11.867221355438232\n",
      "has got 400 stock data, achieve 0.4, cost 13.74040675163269\n",
      "has got 450 stock data, achieve 0.45, cost 15.304674625396729\n",
      "has got 500 stock data, achieve 0.5, cost 16.82099437713623\n",
      "has got 550 stock data, achieve 0.55, cost 18.312580108642578\n",
      "has got 600 stock data, achieve 0.6, cost 20.299575567245483\n",
      "has got 650 stock data, achieve 0.65, cost 21.822168588638306\n",
      "has got 700 stock data, achieve 0.7, cost 23.549716234207153\n",
      "has got 750 stock data, achieve 0.75, cost 25.23026442527771\n",
      "has got 800 stock data, achieve 0.8, cost 26.89245319366455\n",
      "has got 850 stock data, achieve 0.85, cost 28.49739670753479\n",
      "has got 900 stock data, achieve 0.9, cost 30.4950213432312\n",
      "has got 950 stock data, achieve 0.95, cost 32.24170231819153\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "start_time = time.time()\n",
    "# 每次从未获取成功的股票循环获取，而不是每次都重新开始\n",
    "pending_stock_list = list(set(total_stock_list) - set(stock_hist_dict))\n",
    "\n",
    "for num, stock_id in enumerate(pending_stock_list):\n",
    "    if num % 50 == 0:\n",
    "        print(f'has got {num} stock data, achieve {num/len(pending_stock_list)}, cost {time.time()-start_time}')\n",
    "    tmp_df = ak.stock_zh_a_hist(symbol=stock_id, period=\"daily\", start_date=start_date, end_date=end_date, adjust=adjust)\n",
    "    stock_hist_dict[stock_id] = tmp_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "id": "6c0d48de-742e-430b-b2fe-6600b6ed39dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "increment_hist_df = pd.DataFrame()\n",
    "for k, v in stock_hist_dict.items():\n",
    "    tmp_df = v\n",
    "    tmp_df['股票代码'] = k\n",
    "    increment_hist_df = pd.concat([increment_hist_df, tmp_df], axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "id": "2bca1485-9c96-4132-afb9-540e8c6294dd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>收盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>换手率</th>\n",
       "      <th>股票代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>40.24</td>\n",
       "      <td>43.11</td>\n",
       "      <td>44.06</td>\n",
       "      <td>40.24</td>\n",
       "      <td>18456</td>\n",
       "      <td>7.651666e+07</td>\n",
       "      <td>9.39</td>\n",
       "      <td>5.95</td>\n",
       "      <td>2.42</td>\n",
       "      <td>5.03</td>\n",
       "      <td>688398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>10.47</td>\n",
       "      <td>10.88</td>\n",
       "      <td>10.93</td>\n",
       "      <td>10.46</td>\n",
       "      <td>78371</td>\n",
       "      <td>8.292297e+07</td>\n",
       "      <td>4.50</td>\n",
       "      <td>4.11</td>\n",
       "      <td>0.43</td>\n",
       "      <td>3.40</td>\n",
       "      <td>300891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>32.86</td>\n",
       "      <td>33.58</td>\n",
       "      <td>33.69</td>\n",
       "      <td>32.86</td>\n",
       "      <td>263980</td>\n",
       "      <td>1.832052e+08</td>\n",
       "      <td>2.53</td>\n",
       "      <td>2.28</td>\n",
       "      <td>0.75</td>\n",
       "      <td>1.28</td>\n",
       "      <td>600409</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>83.33</td>\n",
       "      <td>86.13</td>\n",
       "      <td>88.61</td>\n",
       "      <td>83.11</td>\n",
       "      <td>11590</td>\n",
       "      <td>9.952018e+07</td>\n",
       "      <td>6.60</td>\n",
       "      <td>3.32</td>\n",
       "      <td>2.77</td>\n",
       "      <td>2.03</td>\n",
       "      <td>688259</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>25.81</td>\n",
       "      <td>26.35</td>\n",
       "      <td>26.50</td>\n",
       "      <td>25.64</td>\n",
       "      <td>71347</td>\n",
       "      <td>5.887496e+07</td>\n",
       "      <td>3.35</td>\n",
       "      <td>2.53</td>\n",
       "      <td>0.65</td>\n",
       "      <td>1.96</td>\n",
       "      <td>600505</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>76.83</td>\n",
       "      <td>83.86</td>\n",
       "      <td>83.86</td>\n",
       "      <td>74.53</td>\n",
       "      <td>28097</td>\n",
       "      <td>2.288554e+08</td>\n",
       "      <td>12.24</td>\n",
       "      <td>9.99</td>\n",
       "      <td>7.62</td>\n",
       "      <td>16.84</td>\n",
       "      <td>001223</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>55.66</td>\n",
       "      <td>57.74</td>\n",
       "      <td>58.57</td>\n",
       "      <td>55.66</td>\n",
       "      <td>201215</td>\n",
       "      <td>2.183924e+08</td>\n",
       "      <td>5.24</td>\n",
       "      <td>3.92</td>\n",
       "      <td>2.18</td>\n",
       "      <td>3.12</td>\n",
       "      <td>002428</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>30.19</td>\n",
       "      <td>31.60</td>\n",
       "      <td>31.89</td>\n",
       "      <td>30.07</td>\n",
       "      <td>21790</td>\n",
       "      <td>5.154127e+07</td>\n",
       "      <td>6.04</td>\n",
       "      <td>4.95</td>\n",
       "      <td>1.49</td>\n",
       "      <td>5.64</td>\n",
       "      <td>300836</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>33.39</td>\n",
       "      <td>34.29</td>\n",
       "      <td>34.43</td>\n",
       "      <td>33.17</td>\n",
       "      <td>108980</td>\n",
       "      <td>1.809125e+08</td>\n",
       "      <td>3.78</td>\n",
       "      <td>2.82</td>\n",
       "      <td>0.94</td>\n",
       "      <td>5.29</td>\n",
       "      <td>002213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-02-01</td>\n",
       "      <td>134.73</td>\n",
       "      <td>140.73</td>\n",
       "      <td>141.34</td>\n",
       "      <td>133.98</td>\n",
       "      <td>353515</td>\n",
       "      <td>7.059513e+08</td>\n",
       "      <td>5.48</td>\n",
       "      <td>4.77</td>\n",
       "      <td>6.41</td>\n",
       "      <td>8.52</td>\n",
       "      <td>300075</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            日期      开盘      收盘      最高      最低     成交量           成交额     振幅  \\\n",
       "0   2023-02-01   40.24   43.11   44.06   40.24   18456  7.651666e+07   9.39   \n",
       "0   2023-02-01   10.47   10.88   10.93   10.46   78371  8.292297e+07   4.50   \n",
       "0   2023-02-01   32.86   33.58   33.69   32.86  263980  1.832052e+08   2.53   \n",
       "0   2023-02-01   83.33   86.13   88.61   83.11   11590  9.952018e+07   6.60   \n",
       "0   2023-02-01   25.81   26.35   26.50   25.64   71347  5.887496e+07   3.35   \n",
       "..         ...     ...     ...     ...     ...     ...           ...    ...   \n",
       "0   2023-02-01   76.83   83.86   83.86   74.53   28097  2.288554e+08  12.24   \n",
       "0   2023-02-01   55.66   57.74   58.57   55.66  201215  2.183924e+08   5.24   \n",
       "0   2023-02-01   30.19   31.60   31.89   30.07   21790  5.154127e+07   6.04   \n",
       "0   2023-02-01   33.39   34.29   34.43   33.17  108980  1.809125e+08   3.78   \n",
       "0   2023-02-01  134.73  140.73  141.34  133.98  353515  7.059513e+08   5.48   \n",
       "\n",
       "     涨跌幅   涨跌额    换手率    股票代码  \n",
       "0   5.95  2.42   5.03  688398  \n",
       "0   4.11  0.43   3.40  300891  \n",
       "0   2.28  0.75   1.28  600409  \n",
       "0   3.32  2.77   2.03  688259  \n",
       "0   2.53  0.65   1.96  600505  \n",
       "..   ...   ...    ...     ...  \n",
       "0   9.99  7.62  16.84  001223  \n",
       "0   3.92  2.18   3.12  002428  \n",
       "0   4.95  1.49   5.64  300836  \n",
       "0   2.82  0.94   5.29  002213  \n",
       "0   4.77  6.41   8.52  300075  \n",
       "\n",
       "[1000 rows x 12 columns]"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "increment_hist_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "id": "1a05d8f2-965e-45a3-a569-46d895fa13d7",
   "metadata": {},
   "outputs": [],
   "source": [
    "daybar_sql = \"INSERT INTO stock_daybar(date, code, open, high, low, close, volume, turnover) \"\\\n",
    "             \"VALUES (%s, %s, %s, %s, %s, %s, %s, %s);\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "id": "f31f1250-5d69-4d1c-b906-e86d5f2c966d",
   "metadata": {},
   "outputs": [],
   "source": [
    "increment_daybar_df = increment_hist_df.loc[:, ['日期', '股票代码', '开盘', '最高', '最低', '收盘', '成交量', '成交额']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 191,
   "id": "1c736e47-45f9-4165-a940-05a39324e900",
   "metadata": {},
   "outputs": [],
   "source": [
    "try:\n",
    "    # 批量执行多条插入SQL语句\n",
    "    cursor.executemany(daybar_sql, increment_daybar_df.values.tolist())\n",
    "    # 提交事务\n",
    "    conn.commit()\n",
    "except Exception as e:\n",
    "    print(e)\n",
    "    # 有异常，回滚事务\n",
    "    conn.rollback()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3701a940-f36f-472a-ba1a-b2ea9e547879",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "toc-autonumbering": true
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
